Skip to content

Commit

Permalink
JIT: Fixed numeric string index handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Nov 1, 2021
1 parent cd32b47 commit f1e6a7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin
if (_zend_handle_numeric_str_ex(str->val, str->len, &idx)) {
retval = zend_hash_index_find(ht, idx);
if (!retval) {
if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
if (UNEXPECTED(zend_undefined_offset_write(ht, idx) == FAILURE)) {
return NULL;
}
retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
Expand Down
17 changes: 17 additions & 0 deletions ext/opcache/tests/jit/fetch_dim_rw_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
JIT FETCH_DIM_RW: 002
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
$a = [];
$k = "0";
$a[$k]++;
var_dump($a[$k]);
?>
--EXPECTF--
Warning: Undefined array key 0 in %sfetch_dim_rw_002.php on line 4
int(1)

0 comments on commit f1e6a7d

Please sign in to comment.