com php-src: Followup fix for ef9ed19e, see also bug #76738: ext/dom/document.c
| From: | Anatol Belski | Date: | Tue, 14 Aug 2018 12:16:13 +0000 |
| Subject: | com php-src: Followup fix for ef9ed19e, see also bug #76738: ext/dom/document.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102878@lists.php.net to get a copy of this message | ||
Commit: 083285f22a74989689f97d1d53476e7eaec35acc
Author: Anatol Belski <ab@php.net> Tue, 14 Aug 2018 14:14:05 +0200
Parents: e2326c58164ca0f4eacba0ac89b44abec1fe402a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=083285f22a74989689f97d1d53476e7eaec35acc
Log:
Followup fix for ef9ed19e, see also bug #76738
Bugs:
https://bugs.php.net/76738
Changed paths:
M ext/dom/document.c
Diff:
diff --git a/ext/dom/document.c b/ext/dom/document.c
index 6bbc050..e167880 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -2152,7 +2152,7 @@ PHP_FUNCTION(dom_document_save_html)
xmlBufferPtr buf;
dom_object *intern, *nodeobj;
xmlChar *mem = NULL;
- int size = 0, format;
+ int format;
dom_doc_propsptr doc_props;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
@@ -2182,39 +2182,26 @@ PHP_FUNCTION(dom_document_save_html)
}
if (node->type == XML_DOCUMENT_FRAG_NODE) {
- int one_size;
-
for (node = node->children; node; node = node->next) {
htmlNodeDumpFormatOutput(outBuf, docp, node, NULL, format);
-#ifdef LIBXML2_NEW_BUFFER
- one_size = !outBuf->error ? xmlOutputBufferGetSize(outBuf) : -1;
-#else
- one_size = !outBuf->error ? outBuf->buffer->use : -1;
-#endif
- if (one_size >= 0) {
- size = one_size;
- } else {
- size = -1;
+ if (outBuf->error) {
break;
}
}
} else {
htmlNodeDumpFormatOutput(outBuf, docp, node, NULL, format);
-#ifdef LIBXML2_NEW_BUFFER
- size = !outBuf->error ? xmlOutputBufferGetSize(outBuf): -1;
-#else
- size = !outBuf->error ? outBuf->buffer->use : -1;
-#endif
}
- if (size >= 0) {
+ if (!outBuf->error) {
+ xmlOutputBufferFlush(outBuf);
#ifdef LIBXML2_NEW_BUFFER
- mem = (xmlChar*) xmlOutputBufferGetContent(outBuf);
+ mem = (xmlChar*) xmlBufferContent(buf);
#else
mem = (xmlChar*) outBuf->buffer->content;
#endif
if (!mem) {
RETVAL_FALSE;
} else {
+ int size = xmlBufferLength(buf);
RETVAL_STRINGL((const char*) mem, size);
}
} else {
@@ -2223,6 +2210,7 @@ PHP_FUNCTION(dom_document_save_html)
}
xmlOutputBufferClose(outBuf);
} else {
+ int size = 0;
#if LIBXML_VERSION >= 20623
htmlDocDumpMemoryFormat(docp, &mem, &size, format);
#else