[xml] Patch for parser.c (free parser context with unsupported encoding )



Hello,

attached is a patch that solves a problem in
libxml2 (version 2.4.19):
When you try to free a parser context that returns
-1 from xmlParseDocument(ctxt) due to an unsupported
encoding, you'll get an abnormal program termination.

Reason:
xmlParseEncodingDecl() sets
  ctxt->input->encoding = encoding;
where "encoding" is the encoding name provided in the
XML declaration.
If the encoding is unsupported, xmlParseEncodingDecl()
calls
  xmlFree(encoding);
so "ctxt->input->encoding" points to nowhereland.
Then xmlFreeParserCtxt() calls xmlFreeInputStream()
which tries to free the "encoding" member of the
input stream (which is not NULL, but invalid). Crash.
So i guess it's correct to set
  ctxt->input->encoding = (xmlChar*)NULL;
together with
  xmlFree(encoding);
in xmlParseEncodingDecl().


Mit freundlichen Gruessen - Kind regards
Markus Henke



________________________Addressed by:________________________
 ORDAT GmbH & Co. KG  -  Serversystems / eCom 
 Dipl.-Inf. (FH) Markus Henke  Fon: +49 (641) 7941-0
 Rathenaustr. 1                Fax: +49 (641) 7941-132
 35394 Gießen                  mailto:markus henke ordat com
 See:                          http://www.ordat.com
_____________________________________________________________
              ...this behavior is by design...


 <<parser.c.patch>> 

Attachment: parser.c.patch
Description: Binary data



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