Skip to content

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented Oct 19, 2025

Based on the patch from @nielsdos and split into different commits to explain what affects what.

@alexandre-daubois
Copy link
Member

Not approving as it's still in draft, but looks good. Thanks for taking care of this!

@Girgias Girgias linked an issue Oct 20, 2025 that may be closed by this pull request
@Girgias Girgias changed the base branch from master to PHP-8.5 October 20, 2025 16:00
@Girgias Girgias marked this pull request as ready for review October 21, 2025 12:24
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Comment on lines +6281 to +6286
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know, each new warning opens a way to modify some involved zval through the user error handler.
In this case, user error handler may probably unset() op1 and this may lead to use-after-free on attempt to add new element.

It's better to add related test(s) and fix problem at first place.

cc @iluuu1994 @nielsdos

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed:

set_error_handler(function ($errno, $errstr) {
    var_dump($errstr);
    global $a;
    unset($a);
});

$a = new stdClass;
$b = [0, null => $a];

I usually spot those, but missed this one.

I hope we can come up with a general solution to avoid these issues (#20018 / #12805).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using null as an array offset is not deprecated

4 participants