File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -3571,7 +3571,8 @@ PHP_FUNCTION(array_pop)
3571
3571
break ;
3572
3572
}
3573
3573
}
3574
- RETVAL_COPY_DEREF (val );
3574
+ RETVAL_COPY_VALUE (val );
3575
+ ZVAL_UNDEF (val );
3575
3576
3576
3577
if (idx == (Z_ARRVAL_P (stack )-> nNextFreeElement - 1 )) {
3577
3578
Z_ARRVAL_P (stack )-> nNextFreeElement = Z_ARRVAL_P (stack )-> nNextFreeElement - 1 ;
@@ -3595,7 +3596,8 @@ PHP_FUNCTION(array_pop)
3595
3596
break ;
3596
3597
}
3597
3598
}
3598
- RETVAL_COPY_DEREF (val );
3599
+ RETVAL_COPY_VALUE (val );
3600
+ ZVAL_UNDEF (val );
3599
3601
3600
3602
if (!p -> key && (zend_long )p -> h == (Z_ARRVAL_P (stack )-> nNextFreeElement - 1 )) {
3601
3603
Z_ARRVAL_P (stack )-> nNextFreeElement = Z_ARRVAL_P (stack )-> nNextFreeElement - 1 ;
@@ -3605,6 +3607,10 @@ PHP_FUNCTION(array_pop)
3605
3607
zend_hash_del_bucket (Z_ARRVAL_P (stack ), p );
3606
3608
}
3607
3609
zend_hash_internal_pointer_reset (Z_ARRVAL_P (stack ));
3610
+
3611
+ if (Z_ISREF_P (return_value )) {
3612
+ zend_unwrap_reference (return_value );
3613
+ }
3608
3614
}
3609
3615
/* }}} */
3610
3616
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17447 (Assertion failure when array poping a self addressing variable)
3
+ --FILE--
4
+ <?php
5
+ $ input [] = &$ input ;
6
+ var_dump (array_pop ($ input ), $ input );
7
+ ?>
8
+ --EXPECT--
9
+ array(0) {
10
+ }
11
+ array(0) {
12
+ }
You can’t perform that action at this time.
0 commit comments