diff --git a/Zend/tests/bug70662.phpt b/Zend/tests/bug70662.phpt new file mode 100644 index 00000000000..2bda8141bab --- /dev/null +++ b/Zend/tests/bug70662.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #70662: Duplicate array key via undefined index error handler +--FILE-- + +--EXPECT-- +array(1) { + ["b"]=> + int(1) +} diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index f88ccb1ea70..5b98fb47fb0 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1557,7 +1557,8 @@ num_index: break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, hval); - /* break missing intentionally */ + retval = zend_hash_index_update(ht, hval, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); break; @@ -1605,7 +1606,8 @@ str_index: break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(offset_key)); - /* break missing intentionally */ + retval = zend_hash_update(ht, offset_key, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(ht, offset_key, &EG(uninitialized_zval)); break; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f0e7278459f..0c34f1717bc 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1565,7 +1565,8 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMPVAR|CV, UNUSED|CONST|V break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 035f4ab7af0..031e234281b 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -5024,7 +5024,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -6945,7 +6946,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -7441,7 +7443,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -31092,7 +31095,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -33305,7 +33309,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -34242,7 +34247,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -41434,7 +41440,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -42415,7 +42422,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; @@ -42816,7 +42824,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_ break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name)); - /* break missing intentionally */ + retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval)); + break; case BP_VAR_W: retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break;