File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ PHP NEWS
56
56
. Fixed bug #79701 (getElementById does not correctly work with duplicate
57
57
definitions). (nielsdos)
58
58
. Implemented "New ext-dom features in PHP 8.4" RFC. (nielsdos)
59
+ . Fixed GH-14698 (segfault on DOM node dereference). (David Carlier)
59
60
60
61
- Fileinfo:
61
62
. Update to libmagic 5.45. (nielsdos)
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-14698 crash on DOM node dereference
3
+ --EXTENSIONS--
4
+ dom
5
+ --CREDITS--
6
+ YuanchengJiang
7
+ --FILE--
8
+ <?php
9
+ $ dom = new DOMDocument ;
10
+ $ dom ->loadHTML ('<span title="y">x</span><span title="z">x</span> ' );
11
+ $ html = simplexml_import_dom ($ dom );
12
+ foreach ($ html ->body ->span as $ obj ) {
13
+ }
14
+ $ script1_dataflow = $ html ;
15
+ $ array = ['foo ' ];
16
+ foreach ($ array as $ key => &$ value ) {
17
+ unset($ script1_dataflow [$ key ]);
18
+ }
19
+ echo "DONE " ;
20
+ ?>
21
+ --EXPECTF--
22
+ DONE
Original file line number Diff line number Diff line change @@ -329,9 +329,13 @@ PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node)
329
329
/* This ensures that namespace references in this subtree are defined within this subtree,
330
330
* otherwise a use-after-free would be possible when the original namespace holder gets freed. */
331
331
php_libxml_node_ptr * ptr = curnode -> _private ;
332
- php_libxml_node_object * obj = ptr -> _private ;
333
- if (!obj -> document || obj -> document -> class_type < PHP_LIBXML_CLASS_MODERN ) {
334
- xmlReconciliateNs (curnode -> doc , curnode );
332
+
333
+ /* Checking in case it runs out of reference */
334
+ if (ptr -> _private ) {
335
+ php_libxml_node_object * obj = ptr -> _private ;
336
+ if (!obj -> document || obj -> document -> class_type < PHP_LIBXML_CLASS_MODERN ) {
337
+ xmlReconciliateNs (curnode -> doc , curnode );
338
+ }
335
339
}
336
340
}
337
341
/* Skip freeing */
You can’t perform that action at this time.
0 commit comments