Skip to content

Commit 91842e0

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix GH-21688: SEGV in C14N on empty HTMLDocument.
2 parents 55c2dbb + 19f73c5 commit 91842e0

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

ext/dom/node.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,11 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
22632263
}
22642264

22652265
zend_hash_init(&links, 0, NULL, NULL, false);
2266-
dom_relink_ns_decls(&links, xmlDocGetRootElement(docp));
2266+
xmlNodePtr root_element = xmlDocGetRootElement(docp);
2267+
2268+
if (root_element) {
2269+
dom_relink_ns_decls(&links, root_element);
2270+
}
22672271
} else if (!docp) {
22682272
/* Note: not triggerable with modern DOM */
22692273
zend_throw_error(NULL, "Node must be associated with a document");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
GH-21688 (SEGV in C14N on empty HTMLDocument)
3+
--CREDITS--
4+
YuanchengJiang
5+
--EXTENSIONS--
6+
dom
7+
--FILE--
8+
<?php
9+
$dom = Dom\HTMLDocument::createEmpty();
10+
var_dump($dom->C14N());
11+
?>
12+
--EXPECT--
13+
string(0) ""

0 commit comments

Comments
 (0)