[xml] Memory tag errors on xmlCleanupCharEncodingHandlers

I believe I've found a bug, or at least annoying issue in libxml2.

So I've got a library that is using libxml2 heavily. I had to turn on memory tracking in the so I can inspect the total memory allocated by libxml2.

xmlMemSetup(xmlMemFree, xmlMemMalloc, xmlMemRealloc, xmlMemoryStrdup);

// http://github.com/polotek/libxmljs/blob/master/src/libxmljs.cc#L160-161

But now I get the Memory tag errors that occur when xml memory isn't allocated or freed properly. ÂI've studied this issue a lot because I thought it might be a problem of mine. ÂHere's an example thread below (not mine, just helped me understand the problem).


I understand things now and I've been debugging to track down where this happens. ÂDespite what I might be doing in my library, I always get several memory errors. ÂI've traced the problem to the functionÂxmlCleanupCharEncodingHandlers that gets called in xmlCleanupParser.

The function calls xmlFree on all of the names of the handlers. ÂBut the names were not created with xmlMalloc. ÂThey are passed in as literal strings. ÂSee ecoding.c around line 1351.

I know this issue doesn't cause a real problem in practice. ÂBut I have to have the memory tracking on in the release version of my lib. ÂSo everyone who uses it sees these and it causes them to think it's broken. ÂIt would be awesome if this was fixed in a future release of libxml2. ÂBut what I really need is a way to prevent it happening in previous versions whenever memory tracking is on.

I hope this makes sense. ÂAny help is appreciated.


Marco Rogers
marco rogers gmail com

Life is ten percent what happens to you and ninety percent how you respond to it.
- Lou Holtz

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]