Skip to content

Commit d6831e9

Browse files
committed
Revert Fixed bug #79451
The fix for 8.1 and above is not identical and I don't know how to fix without breaking the whole build apparently
1 parent ba029fc commit d6831e9

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

NEWS

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ PHP NEWS
66
. Fixed bug GH-9323 (Crash in ZEND_RETURN/GC/zend_call_function)
77
(Tim Starling)
88

9-
- DOM:
10-
. Fixed bug #79451 (Using DOMDocument->replaceChild on doctype causes
11-
double free) (NathanFreeman)
12-
139
- Streams:
1410
. Fixed bug GH-9316 ($http_response_header is wrong for long status line).
1511
(cmb, timwolla)

ext/dom/node.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#endif
2121

2222
#include "php.h"
23-
2423
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
2524
#include "php_dom.h"
2625

@@ -1002,7 +1001,6 @@ PHP_METHOD(DOMNode, replaceChild)
10021001
xmlNodePtr children, newchild, oldchild, nodep;
10031002
dom_object *intern, *newchildobj, *oldchildobj;
10041003
int foundoldchild = 0, stricterror;
1005-
bool replacedoctype = false;
10061004

10071005
int ret;
10081006

@@ -1065,21 +1063,13 @@ PHP_METHOD(DOMNode, replaceChild)
10651063
dom_reconcile_ns(nodep->doc, newchild);
10661064
}
10671065
} else if (oldchild != newchild) {
1068-
xmlDtdPtr intSubset = xmlGetIntSubset(nodep->doc);
1069-
replacedoctype = (intSubset == (xmlDtd *) oldchild);
1070-
10711066
if (newchild->doc == NULL && nodep->doc != NULL) {
10721067
xmlSetTreeDoc(newchild, nodep->doc);
10731068
newchildobj->document = intern->document;
10741069
php_libxml_increment_doc_ref((php_libxml_node_object *)newchildobj, NULL);
10751070
}
1076-
10771071
xmlReplaceNode(oldchild, newchild);
10781072
dom_reconcile_ns(nodep->doc, newchild);
1079-
1080-
if (replacedoctype) {
1081-
nodep->doc->intSubset = (xmlDtd *) newchild;
1082-
}
10831073
}
10841074
DOM_RET_OBJ(oldchild, &ret, intern);
10851075
return;
@@ -1678,7 +1668,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
16781668
buf = xmlAllocOutputBuffer(NULL);
16791669
}
16801670

1681-
if (buf != NULL) {
1671+
if (buf != NULL) {
16821672
ret = xmlC14NDocSaveTo(docp, nodeset, exclusive, inclusive_ns_prefixes,
16831673
with_comments, buf);
16841674
}
@@ -1693,9 +1683,9 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
16931683
xmlXPathFreeContext(ctxp);
16941684
}
16951685

1696-
if (buf == NULL || ret < 0) {
1697-
RETVAL_FALSE;
1698-
} else {
1686+
if (buf == NULL || ret < 0) {
1687+
RETVAL_FALSE;
1688+
} else {
16991689
if (mode == 0) {
17001690
#ifdef LIBXML2_NEW_BUFFER
17011691
ret = xmlOutputBufferGetSize(buf);
@@ -1712,7 +1702,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
17121702
RETVAL_EMPTY_STRING();
17131703
}
17141704
}
1715-
}
1705+
}
17161706

17171707
if (buf) {
17181708
int bytes;

0 commit comments

Comments
 (0)