Skip to content

Commit 3ff3199

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix registerNodeClass with abstract class crashing
2 parents 82c2143 + f5d1a19 commit 3ff3199

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ext/dom/document.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,10 @@ PHP_METHOD(DOMDocument, registerNodeClass)
20722072
}
20732073

20742074
if (ce == NULL || instanceof_function(ce, basece)) {
2075+
if (UNEXPECTED(ce != NULL && (ce->ce_flags & ZEND_ACC_ABSTRACT))) {
2076+
zend_argument_value_error(2, "must not be an abstract class");
2077+
RETURN_THROWS();
2078+
}
20752079
DOM_GET_THIS_INTERN(intern);
20762080
dom_set_doc_classmap(intern->document, basece, ce);
20772081
RETURN_TRUE;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
registerNodeClass() with an abstract class should fail
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
abstract class Test extends DOMElement {
9+
abstract function foo();
10+
}
11+
12+
$dom = new DOMDocument;
13+
14+
try {
15+
$dom->registerNodeClass("DOMElement", "Test");
16+
} catch (ValueError $e) {
17+
echo "ValueError: ", $e->getMessage(), "\n";
18+
}
19+
20+
$dom->createElement("foo");
21+
22+
?>
23+
--EXPECT--
24+
ValueError: DOMDocument::registerNodeClass(): Argument #2 ($extendedClass) must not be an abstract class

0 commit comments

Comments
 (0)