Skip to content

Commit 476455b

Browse files
committed
Fix mem leak
1 parent a5509da commit 476455b

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Do not leak when promoting null offset deprecation
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(function ($errno, $errstr) {
7+
throw new Exception($errstr);
8+
});
9+
10+
try {
11+
$a = ['foo' => 'bar', null => new stdClass];
12+
} catch (Throwable $e) {
13+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
14+
}
15+
?>
16+
--EXPECT--
17+
Exception: Using null as an array offset is deprecated, use an empty string instead

Zend/zend_vm_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6281,6 +6281,7 @@ ZEND_VM_C_LABEL(num_index):
62816281
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
62826282
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
62836283
if (UNEXPECTED(EG(exception))) {
6284+
zval_ptr_dtor_nogc(expr_ptr);
62846285
HANDLE_EXCEPTION();
62856286
}
62866287
str = ZSTR_EMPTY_ALLOC();

Zend/zend_vm_execute.h

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)