com php-src: Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML(): ext/simplexml/simplexml.c

From: Date: Thu, 13 Oct 2016 23:42:05 +0000
Subject: com php-src: Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML(): ext/simplexml/simplexml.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95080@lists.php.net to get a copy of this message
Commit: e7e60851ae2a3ce47a317b93e080e4daa7120934 Author: Stanislav Malyshev <stas@php.net> Tue, 11 Oct 2016 13:30:52 -0700 Committer: Anatol Belski <ab@php.net> Fri, 14 Oct 2016 01:42:05 +0200 Parents: 8e2c9024a6755c092f80b385aa7b7487efdc8acc Branches: PHP-7.1 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e7e60851ae2a3ce47a317b93e080e4daa7120934 Log: Fix bug #73293 - NULL pointer dereference in SimpleXMLElement::asXML() (cherry picked from commit 96a8cf8e1b5dc1b0c708bb5574e0d6727cc56d9e) (cherry picked from commit 4ef79370a82d6c92f4ea0cd462274ba24e007f56) Bugs: https://bugs.php.net/73293 Changed paths: M ext/simplexml/simplexml.c Diff: diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index fdda304...1f75052 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1474,9 +1474,15 @@ SXE_METHOD(asXML) if (node) { if (node->parent && (XML_DOCUMENT_NODE == node->parent->type)) { xmlDocDumpMemoryEnc((xmlDocPtr) sxe->document->ptr, &strval, &strval_len, (const char *) ((xmlDocPtr) sxe->document->ptr)->encoding); - RETVAL_STRINGL((char *)strval, strval_len); + if (!strval) { + RETVAL_FALSE; + } else { + RETVAL_STRINGL((char *)strval, strval_len); + } xmlFree(strval); } else { + char *return_content; + size_t return_len; /* Should we be passing encoding information instead of NULL? */ outbuf = xmlAllocOutputBuffer(NULL); @@ -1487,10 +1493,17 @@ SXE_METHOD(asXML) xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, (const char *) ((xmlDocPtr) sxe->document->ptr)->encoding); xmlOutputBufferFlush(outbuf); #ifdef LIBXML2_NEW_BUFFER - RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), xmlOutputBufferGetSize(outbuf)); + return_content = (char *)xmlOutputBufferGetContent(outbuf); + return_len = xmlOutputBufferGetSize(outbuf); #else - RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use); + return_content = (char *)outbuf->buffer->content; + return_len = outbuf->buffer->use; #endif + if (return_content) { + RETVAL_FALSE; + } else { + RETVAL_STRINGL(return_content, return_len); + } xmlOutputBufferClose(outbuf); } } else {

« previous php.cvs (#95080) next »