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

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix registerNodeClass with abstract class crashing
This commit is contained in:
Niels Dossche
2023-10-13 19:10:51 +02:00
3 changed files with 31 additions and 0 deletions

3
NEWS
View File

@@ -5,6 +5,9 @@ PHP NEWS
- Core:
. Fixed double-free of non-interned enum case name. (ilutov)
- DOM:
. Fix registerNodeClass with abstract class crashing. (nielsdos)
- Fiber:
. Fixed bug GH-11121 (ReflectionFiber segfault). (danog, trowski, bwoebi)

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