[xml] SEGV...using the api correctly?

On Win7 32bit in an simple validation app using a statically linked libxml2, the following code SEGV's


at line 114 in `xmlFreeParserInputBuffer(input)` with the following gdb info:

C:\projects\xvalid-git>gdb --args xval.exe --xsd test\nested.xsd test\nested.xml
Breakpoint 1, xvalid__xsd_validate (ctx=0x22fe88) at src/xvalid.c:107
107             xsd_valid_ctx = NULL;
(gdb) s
108             xmlFreeParserInputBuffer(input);
xmlFreeParserInputBuffer (in=0x2f1f98) at xmlIO.c:2417
2417        if (in == NULL) return;
2419        if (in->raw) {
2420            xmlBufferFree(in->raw);
xmlBufferFree (buf=0xfeeefeee) at tree.c:6980
6980        if (buf == NULL) {
6988        if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&

Program received signal SIGSEGV, Segmentation fault.
xmlBufferFree (buf=0xfeeefeee) at tree.c:6988
6988        if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&

I statically link to a mingw gcc 4.6.2 built libxml2 v2.7.8 configured as:


I'm ramping up on the codebase and API so I don't yet grok the API. Deleting lines 114 and 115 make the SEGV 
go away, but I think removing those lines is wrong as I want to iterate over a bunch of xml files, validate 
each one, and then cleanup between iterations.

While the last part of the gdb trace surprises me, I'd like to better understand how the API *should* be used 
in this XSD validation scenario as I'm clearly not doing it right.

In general, when and how should `xmlFreeXXX` fcns be used, and what specifically am I doing wrong in my 


blog: http://jonforums.github.com/
twitter: @jonforums

"Anyone who can only think of one way to spell a word obviously lacks imagination." - Mark Twain

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