@@ -287,6 +287,24 @@ static int ZEND_FASTCALL zend_jit_undefined_op_helper(uint32_t var)
287
287
return EG (exception ) == NULL ;
288
288
}
289
289
290
+ static int ZEND_FASTCALL zend_jit_undefined_op_helper_write (HashTable * ht , uint32_t var )
291
+ {
292
+ const zend_execute_data * execute_data = EG (current_execute_data );
293
+ zend_string * cv = EX (func )-> op_array .vars [EX_VAR_TO_NUM (var )];
294
+
295
+ /* The array may be destroyed while throwing the notice.
296
+ * Temporarily increase the refcount to detect this situation. */
297
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE )) {
298
+ GC_ADDREF (ht );
299
+ }
300
+ zend_error (E_WARNING , "Undefined variable $%s" , ZSTR_VAL (cv ));
301
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE ) && !GC_DELREF (ht )) {
302
+ zend_array_destroy (ht );
303
+ return 0 ;
304
+ }
305
+ return EG (exception ) == NULL ;
306
+ }
307
+
290
308
static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper (zend_array * ht , zval * dim , zval * result )
291
309
{
292
310
zend_long hval ;
@@ -513,7 +531,9 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di
513
531
offset_key = Z_STR_P (dim );
514
532
goto str_index ;
515
533
case IS_UNDEF :
516
- zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
534
+ if (!zend_jit_undefined_op_helper_write (ht , EG (current_execute_data )-> opline -> op2 .var )) {
535
+ return NULL ;
536
+ }
517
537
/* break missing intentionally */
518
538
case IS_NULL :
519
539
offset_key = ZSTR_EMPTY_ALLOC ();
@@ -588,7 +608,9 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim
588
608
offset_key = Z_STR_P (dim );
589
609
goto str_index ;
590
610
case IS_UNDEF :
591
- zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
611
+ if (!zend_jit_undefined_op_helper_write (ht , EG (current_execute_data )-> opline -> op2 .var )) {
612
+ return NULL ;
613
+ }
592
614
/* break missing intentionally */
593
615
case IS_NULL :
594
616
offset_key = ZSTR_EMPTY_ALLOC ();
0 commit comments