File tree 3 files changed +14
-2
lines changed
3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ PHP NEWS
6
6
. Fixed bug GH-9323 (Crash in ZEND_RETURN/GC/zend_call_function)
7
7
(Tim Starling)
8
8
9
+ - DOM:
10
+ . Fixed bug #79451 (DOMDocument->replaceChild on doctype causes double free).
11
+ (Nathan Freeman)
12
+
9
13
- Streams:
10
14
. Fixed bug GH-9316 ($http_response_header is wrong for long status line).
11
15
(cmb, timwolla)
Original file line number Diff line number Diff line change @@ -1003,6 +1003,7 @@ PHP_METHOD(DOMNode, replaceChild)
1003
1003
xmlNodePtr newchild , oldchild , nodep ;
1004
1004
dom_object * intern , * newchildobj , * oldchildobj ;
1005
1005
int stricterror ;
1006
+ bool replacedoctype = false;
1006
1007
1007
1008
int ret ;
1008
1009
@@ -1059,13 +1060,20 @@ PHP_METHOD(DOMNode, replaceChild)
1059
1060
dom_reconcile_ns (nodep -> doc , newchild );
1060
1061
}
1061
1062
} else if (oldchild != newchild ) {
1063
+ xmlDtdPtr intSubset = xmlGetIntSubset (nodep -> doc );
1064
+ replacedoctype = (intSubset == (xmlDtd * ) oldchild );
1065
+
1062
1066
if (newchild -> doc == NULL && nodep -> doc != NULL ) {
1063
1067
xmlSetTreeDoc (newchild , nodep -> doc );
1064
1068
newchildobj -> document = intern -> document ;
1065
1069
php_libxml_increment_doc_ref ((php_libxml_node_object * )newchildobj , NULL );
1066
1070
}
1067
1071
xmlReplaceNode (oldchild , newchild );
1068
1072
dom_reconcile_ns (nodep -> doc , newchild );
1073
+
1074
+ if (replacedoctype ) {
1075
+ nodep -> doc -> intSubset = (xmlDtd * ) newchild ;
1076
+ }
1069
1077
}
1070
1078
DOM_RET_OBJ (oldchild , & ret , intern );
1071
1079
}
Original file line number Diff line number Diff line change 1
1
--TEST--
2
2
Bug #79451 (Using DOMDocument->replaceChild on doctype causes double free)
3
- --SKIPIF --
4
- <?php require_once ( ' skipif.inc ' ); ?>
3
+ --EXTENSIONS --
4
+ dom
5
5
--FILE--
6
6
<?php
7
7
$ dom = new \DOMDocument ();
You can’t perform that action at this time.
0 commit comments