1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3'

* PHP-8.3:
  Fix registerNodeClass with abstract class crashing
This commit is contained in:
Niels Dossche
2023-10-13 19:11:10 +02:00
2 changed files with 28 additions and 0 deletions

View File

@@ -2072,6 +2072,10 @@ PHP_METHOD(DOMDocument, registerNodeClass)
}
if (ce == NULL || instanceof_function(ce, basece)) {
if (UNEXPECTED(ce != NULL && (ce->ce_flags & ZEND_ACC_ABSTRACT))) {
zend_argument_value_error(2, "must not be an abstract class");
RETURN_THROWS();
}
DOM_GET_THIS_INTERN(intern);
dom_set_doc_classmap(intern->document, basece, ce);
RETURN_TRUE;

View File

@@ -0,0 +1,24 @@
--TEST--
registerNodeClass() with an abstract class should fail
--EXTENSIONS--
dom
--FILE--
<?php
abstract class Test extends DOMElement {
abstract function foo();
}
$dom = new DOMDocument;
try {
$dom->registerNodeClass("DOMElement", "Test");
} catch (ValueError $e) {
echo "ValueError: ", $e->getMessage(), "\n";
}
$dom->createElement("foo");
?>
--EXPECT--
ValueError: DOMDocument::registerNodeClass(): Argument #2 ($extendedClass) must not be an abstract class