• Bart De Schuymer's avatar
    fix memory leak xml header encoding field with XML_PARSE_IGNORE_ENC · 500c54ef
    Bart De Schuymer authored
    When the xml parser encounters an xml encoding in an xml header while
    configured with option XML_PARSE_IGNORE_ENC, it fails to free memory
    allocated for storing the encoding.
    The patch below fixes this.
    How to reproduce:
    1. Change doc/examples/parse4.c to add xmlCtxtUseOptions(ctxt,
    XML_PARSE_IGNORE_ENC); after the call to xmlCreatePushParserCtxt.
    2. Rebuild
    3. run the following command from the top libxml2 directory:
    LD_LIBRARY_PATH=.libs/ valgrind --leak-check=full
    ./doc/examples/.libs/parse4 ./test.xml , where test.xml contains
    following
    input:
    <?xml version="1.0" encoding="UTF-81" ?><hi/>
    valgrind will report:
    ==1964== 10 bytes in 1 blocks are definitely lost in loss record 1 of 1
    ==1964==    at 0x4C272DB: malloc (in
    /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==1964==    by 0x4E88497: xmlParseEncName (parser.c:10224)
    ==1964==    by 0x4E888FE: xmlParseEncodingDecl (parser.c:10295)
    ==1964==    by 0x4E89630: xmlParseXMLDecl (parser.c:10534)
    ==1964==    by 0x4E8B737: xmlParseTryOrFinish (parser.c:11293)
    ==1964==    by 0x4E8E775: xmlParseChunk (parser.c:12283)
    
    Signed-off-by: Bart De Schuymer <bart at amplidata com>
    500c54ef
Name
Last commit
Last update
VxWorks Loading commit data...
bakefile Loading commit data...
doc Loading commit data...
example Loading commit data...
include Loading commit data...
macos Loading commit data...
optim Loading commit data...
os400 Loading commit data...
python Loading commit data...
result Loading commit data...
test Loading commit data...
vms Loading commit data...
win32 Loading commit data...
xstc Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
ChangeLog Loading commit data...
Copyright Loading commit data...
DOCBparser.c Loading commit data...
HACKING Loading commit data...
HTMLparser.c Loading commit data...
HTMLtree.c Loading commit data...
INSTALL.libxml2 Loading commit data...
MAINTAINERS Loading commit data...
Makefile.am Loading commit data...
Makefile.tests Loading commit data...
Makefile.win Loading commit data...
NEWS Loading commit data...
README Loading commit data...
README.cvs-commits Loading commit data...
README.tests Loading commit data...
SAX.c Loading commit data...
SAX2.c Loading commit data...
TODO Loading commit data...
TODO_SCHEMAS Loading commit data...
acinclude.m4 Loading commit data...
autogen.sh Loading commit data...
buf.c Loading commit data...
buf.h Loading commit data...
build_glob.py Loading commit data...
c14n.c Loading commit data...
catalog.c Loading commit data...
check-relaxng-test-suite.py Loading commit data...
check-relaxng-test-suite2.py Loading commit data...
check-xinclude-test-suite.py Loading commit data...
check-xml-test-suite.py Loading commit data...
check-xsddata-test-suite.py Loading commit data...
chvalid.c Loading commit data...
chvalid.def Loading commit data...
configure.ac Loading commit data...
dbgen.pl Loading commit data...
dbgenattr.pl Loading commit data...
debugXML.c Loading commit data...
dict.c Loading commit data...
elfgcchack.h Loading commit data...
enc.h Loading commit data...
encoding.c Loading commit data...
entities.c Loading commit data...
error.c Loading commit data...
genChRanges.py Loading commit data...
genUnicode.py Loading commit data...
gentest.py Loading commit data...
global.data Loading commit data...
globals.c Loading commit data...
hash.c Loading commit data...
legacy.c Loading commit data...
libxml-2.0-uninstalled.pc.in Loading commit data...
libxml-2.0.pc.in Loading commit data...
libxml.3 Loading commit data...
libxml.h Loading commit data...
libxml.m4 Loading commit data...
libxml.spec.in Loading commit data...
libxml2-config.cmake.in Loading commit data...
libxml2.doap Loading commit data...
libxml2.syms Loading commit data...
list.c Loading commit data...
nanoftp.c Loading commit data...
nanohttp.c Loading commit data...
parser.c Loading commit data...
parserInternals.c Loading commit data...
pattern.c Loading commit data...
regressions.py Loading commit data...
regressions.xml Loading commit data...
relaxng.c Loading commit data...
rngparser.c Loading commit data...
runsuite.c Loading commit data...
runtest.c Loading commit data...
runxmlconf.c Loading commit data...
save.h Loading commit data...
schematron.c Loading commit data...
testAutomata.c Loading commit data...
testC14N.c Loading commit data...
testHTML.c Loading commit data...
testModule.c Loading commit data...
testOOM.c Loading commit data...
testOOMlib.c Loading commit data...
testOOMlib.h Loading commit data...
testReader.c Loading commit data...
testRegexp.c Loading commit data...
testRelax.c Loading commit data...
testSAX.c Loading commit data...
testSchemas.c Loading commit data...
testThreads.c Loading commit data...
testThreadsWin32.c Loading commit data...
testURI.c Loading commit data...
testXPath.c Loading commit data...
testapi.c Loading commit data...
testchar.c Loading commit data...
testdict.c Loading commit data...
testdso.c Loading commit data...
testlimits.c Loading commit data...
testrecurse.c Loading commit data...
threads.c Loading commit data...
timsort.h Loading commit data...
tree.c Loading commit data...
trio.c Loading commit data...
trio.h Loading commit data...
triodef.h Loading commit data...
trionan.c Loading commit data...
trionan.h Loading commit data...
triop.h Loading commit data...
triostr.c Loading commit data...
triostr.h Loading commit data...
uri.c Loading commit data...
valid.c Loading commit data...
xinclude.c Loading commit data...
xlink.c Loading commit data...
xml2-config.1 Loading commit data...
xml2-config.in Loading commit data...
xml2Conf.sh.in Loading commit data...
xmlIO.c Loading commit data...
xmlcatalog.c Loading commit data...
xmllint.c Loading commit data...
xmlmemory.c Loading commit data...
xmlmodule.c Loading commit data...
xmlreader.c Loading commit data...
xmlregexp.c Loading commit data...
xmlsave.c Loading commit data...
xmlschemas.c Loading commit data...
xmlschemastypes.c Loading commit data...
xmlstring.c Loading commit data...
xmlunicode.c Loading commit data...
xmlwriter.c Loading commit data...
xpath.c Loading commit data...
xpointer.c Loading commit data...
xzlib.c Loading commit data...
xzlib.h Loading commit data...