On Tue, Oct 14, 2014 at 11:52:56PM +0300, Roumen Petrov wrote:
> Hello,
> 
> Please review patch posted to the list long time ago. You could find
> original report attached in file
> "0015-fix-memory-leak-xml-header-encoding-field-in-combina.patch".
> 
> Regards,
> Roumen Petrov

  Hi Roumen,

all set, 1, 2 and 4 I got the same, 3rd and 6 and 8 make sense though
I had to update the configure.ac patch to cope with new generated file
for cmake, and that one is also right !

  All pushed, thanks a lot !

Daniel

> >From 157b7e3a28466b110b49be49ed1e8a518eb130df Mon Sep 17 00:00:00 2001
> From: Roumen Petrov <bugtr...@roumenpetrov.info>
> Date: Sat, 12 Apr 2014 21:30:26 +0300
> Subject: [PATCH 15/17] fix memory leak xml header encoding field in
>  combination with XML_PARSE_IGNORE_ENC
> 
> From: Bart De Schuymer <desch...@b-virtual.org>
> CC:   Bastiaan Stougie <bastiaan.stou...@amplidata.com>
> Hello,
> 
> 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)
> 
> Best regards,
> Bart
> 
> Signed-off-by: Bart De Schuymer <bart at amplidata com>
> ---
>  parser.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/parser.c b/parser.c
> index b9a37ab..c6220b6 100644
> --- a/parser.c
> +++ b/parser.c
> @@ -10378,8 +10378,10 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
>          /*
>           * Non standard parsing, allowing the user to ignore encoding
>           */
> -        if (ctxt->options & XML_PARSE_IGNORE_ENC)
> -            return(encoding);
> +        if (ctxt->options & XML_PARSE_IGNORE_ENC) {
> +            xmlFree((xmlChar *) encoding);
> +            return(NULL);
> +        }
>  
>       /*
>        * UTF-16 encoding stwich has already taken place at this stage,
> -- 
> 1.8.4
> 

> _______________________________________________
> xml mailing list, project page  http://xmlsoft.org/
> xml@gnome.org
> https://mail.gnome.org/mailman/listinfo/xml


-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to