diff options
author | Anatol Belski <ab@php.net> | 2018-08-17 16:22:35 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-08-17 16:22:35 +0200 |
commit | 0414fff205bad752573a4b2176d9f08afd096196 (patch) | |
tree | dc9d001711eb2475f9d02b7082a90a80e8cef682 | |
parent | aa7777d36c201da595eec848143cbc0842456190 (diff) | |
download | php-git-0414fff205bad752573a4b2176d9f08afd096196.tar.gz |
Fix memory leak
-rw-r--r-- | ext/dom/document.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/dom/document.c b/ext/dom/document.c index aba43f1385..9f9ce5e2f8 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -2175,11 +2175,16 @@ PHP_FUNCTION(dom_document_save_html) } buf = xmlBufferCreate(); - outBuf = xmlOutputBufferCreateBuffer(buf, NULL); - if (!outBuf || !buf) { + if (!buf) { php_error_docref(NULL, E_WARNING, "Could not fetch buffer"); RETURN_FALSE; } + outBuf = xmlOutputBufferCreateBuffer(buf, NULL); + if (!outBuf) { + xmlBufferFree(buf); + php_error_docref(NULL, E_WARNING, "Could not fetch output buffer"); + RETURN_FALSE; + } if (node->type == XML_DOCUMENT_FRAG_NODE) { for (node = node->children; node; node = node->next) { @@ -2205,6 +2210,7 @@ PHP_FUNCTION(dom_document_save_html) RETVAL_FALSE; } xmlOutputBufferClose(outBuf); + xmlBufferFree(buf); } else { int size = 0; #if LIBXML_VERSION >= 20623 |