Skip to content

Commit 632357b

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17991: Assertion failure dom_attr_value_write
2 parents a14301b + 6083dc0 commit 632357b

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

ext/dom/php_dom.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,14 @@ static zend_always_inline const dom_prop_handler *dom_get_prop_handler(const dom
367367

368368
if (obj->prop_handler != NULL) {
369369
if (cache_slot && *cache_slot == obj->prop_handler) {
370-
hnd = *(cache_slot + 1);
370+
hnd = cache_slot[1];
371371
}
372372
if (!hnd) {
373373
hnd = zend_hash_find_ptr(obj->prop_handler, name);
374374
if (cache_slot) {
375-
*cache_slot = obj->prop_handler;
376-
*(cache_slot + 1) = (void *) hnd;
375+
cache_slot[0] = obj->prop_handler;
376+
cache_slot[1] = (void *) hnd;
377+
cache_slot[2] = NULL;
377378
}
378379
}
379380
}

ext/dom/tests/gh17991.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
GH-17991 (Assertion failure dom_attr_value_write)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
$attr = new DOMAttr("r", "iL");
8+
class Box {
9+
public ?Test $value;
10+
}
11+
class Test {
12+
}
13+
function test($box) {
14+
var_dump($box->value = new Test);
15+
}
16+
$box = new Box();
17+
test($box);
18+
test($attr);
19+
?>
20+
--EXPECTF--
21+
object(Test)#%d (0) {
22+
}
23+
24+
Fatal error: Uncaught TypeError: Cannot assign Test to property DOMAttr::$value of type string in %s:%d
25+
Stack trace:
26+
#0 %s(%d): test(Object(DOMAttr))
27+
#1 {main}
28+
thrown in %s on line %d

0 commit comments

Comments
 (0)