Skip to content

Commit 859a11e

Browse files
committed
ext/dom: abort custom __debugInfo() on exception
1 parent 06473b1 commit 859a11e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ext/dom/php_dom.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
523523
ZEND_ASSERT(string_key != NULL);
524524

525525
if (entry->read_func(obj, &value) == FAILURE) {
526-
continue;
526+
zend_array_release(debug_info);
527+
debug_info = NULL;
528+
goto exit;
527529
}
528530

529531
if (Z_TYPE(value) == IS_OBJECT) {
@@ -535,6 +537,7 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
535537
zend_hash_update(debug_info, string_key, &value);
536538
} ZEND_HASH_FOREACH_END();
537539

540+
exit:
538541
zend_string_release_ex(object_str, false);
539542

540543
DOM_G(suppress_warnings) = false;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
DOMNode custom __debugInfo() should abort at the first exception
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$d = new DOMNode;
9+
var_dump($d);
10+
11+
?>
12+
--EXPECTF--
13+
Fatal error: Uncaught DOMException: Invalid State Error in %s:%d
14+
Stack trace:
15+
#0 %s(%d): var_dump(Object(DOMNode))
16+
#1 {main}
17+
thrown in %s on line %d

0 commit comments

Comments
 (0)