@@ -456,6 +456,8 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim,
456
456
zend_ulong hval ;
457
457
zend_string * offset_key ;
458
458
zval * retval ;
459
+ zend_execute_data * execute_data ;
460
+ const zend_op * opline ;
459
461
460
462
if (Z_TYPE_P (dim ) == IS_REFERENCE ) {
461
463
dim = Z_REFVAL_P (dim );
@@ -469,7 +471,31 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim,
469
471
offset_key = Z_STR_P (dim );
470
472
goto str_index ;
471
473
case IS_UNDEF :
474
+ /* The array may be destroyed while throwing the notice.
475
+ * Temporarily increase the refcount to detect this situation. */
476
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE )) {
477
+ GC_ADDREF (ht );
478
+ }
479
+ execute_data = EG (current_execute_data );
480
+ opline = EX (opline );
472
481
zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
482
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE ) && !GC_DELREF (ht )) {
483
+ zend_array_destroy (ht );
484
+ if (opline -> result_type & (IS_VAR | IS_TMP_VAR )) {
485
+ if (EG (exception )) {
486
+ ZVAL_UNDEF (EX_VAR (opline -> result .var ));
487
+ } else {
488
+ ZVAL_NULL (EX_VAR (opline -> result .var ));
489
+ }
490
+ }
491
+ return ;
492
+ }
493
+ if (EG (exception )) {
494
+ if (opline -> result_type & (IS_VAR | IS_TMP_VAR )) {
495
+ ZVAL_UNDEF (EX_VAR (opline -> result .var ));
496
+ }
497
+ return ;
498
+ }
473
499
/* break missing intentionally */
474
500
case IS_NULL :
475
501
offset_key = ZSTR_EMPTY_ALLOC ();
@@ -531,6 +557,8 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim
531
557
zend_ulong hval ;
532
558
zend_string * offset_key ;
533
559
zval * retval ;
560
+ zend_execute_data * execute_data ;
561
+ const zend_op * opline ;
534
562
535
563
if (Z_TYPE_P (dim ) == IS_REFERENCE ) {
536
564
dim = Z_REFVAL_P (dim );
@@ -544,7 +572,31 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim
544
572
offset_key = Z_STR_P (dim );
545
573
goto str_index ;
546
574
case IS_UNDEF :
575
+ /* The array may be destroyed while throwing the notice.
576
+ * Temporarily increase the refcount to detect this situation. */
577
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE )) {
578
+ GC_ADDREF (ht );
579
+ }
580
+ execute_data = EG (current_execute_data );
581
+ opline = EX (opline );
547
582
zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
583
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE ) && !GC_DELREF (ht )) {
584
+ zend_array_destroy (ht );
585
+ if (opline -> result_type & (IS_VAR | IS_TMP_VAR )) {
586
+ if (EG (exception )) {
587
+ ZVAL_UNDEF (EX_VAR (opline -> result .var ));
588
+ } else {
589
+ ZVAL_NULL (EX_VAR (opline -> result .var ));
590
+ }
591
+ }
592
+ return ;
593
+ }
594
+ if (EG (exception )) {
595
+ if (opline -> result_type & (IS_VAR | IS_TMP_VAR )) {
596
+ ZVAL_UNDEF (EX_VAR (opline -> result .var ));
597
+ }
598
+ return ;
599
+ }
548
600
/* break missing intentionally */
549
601
case IS_NULL :
550
602
offset_key = ZSTR_EMPTY_ALLOC ();
@@ -616,7 +668,19 @@ static int ZEND_FASTCALL zend_jit_fetch_dim_isset_helper(zend_array *ht, zval *d
616
668
offset_key = Z_STR_P (dim );
617
669
goto str_index ;
618
670
case IS_UNDEF :
671
+ /* The array may be destroyed while throwing the notice.
672
+ * Temporarily increase the refcount to detect this situation. */
673
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE )) {
674
+ GC_ADDREF (ht );
675
+ }
619
676
zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
677
+ if (!(GC_FLAGS (ht ) & IS_ARRAY_IMMUTABLE ) && !GC_DELREF (ht )) {
678
+ zend_array_destroy (ht );
679
+ return 0 ;
680
+ }
681
+ if (EG (exception )) {
682
+ return 0 ;
683
+ }
620
684
/* break missing intentionally */
621
685
case IS_NULL :
622
686
offset_key = ZSTR_EMPTY_ALLOC ();
0 commit comments