summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-08-17 16:22:35 +0200
committerAnatol Belski <ab@php.net>2018-08-17 16:22:35 +0200
commit0414fff205bad752573a4b2176d9f08afd096196 (patch)
treedc9d001711eb2475f9d02b7082a90a80e8cef682
parentaa7777d36c201da595eec848143cbc0842456190 (diff)
downloadphp-git-0414fff205bad752573a4b2176d9f08afd096196.tar.gz
Fix memory leak
-rw-r--r--ext/dom/document.c10
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