File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 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)
35713571 break ;
35723572 }
35733573 }
3574- RETVAL_COPY_DEREF (val );
3574+ RETVAL_COPY_VALUE (val );
3575+ ZVAL_UNDEF (val );
35753576
35763577 if (idx == (Z_ARRVAL_P (stack )-> nNextFreeElement - 1 )) {
35773578 Z_ARRVAL_P (stack )-> nNextFreeElement = Z_ARRVAL_P (stack )-> nNextFreeElement - 1 ;
@@ -3595,7 +3596,8 @@ PHP_FUNCTION(array_pop)
35953596 break ;
35963597 }
35973598 }
3598- RETVAL_COPY_DEREF (val );
3599+ RETVAL_COPY_VALUE (val );
3600+ ZVAL_UNDEF (val );
35993601
36003602 if (!p -> key && (zend_long )p -> h == (Z_ARRVAL_P (stack )-> nNextFreeElement - 1 )) {
36013603 Z_ARRVAL_P (stack )-> nNextFreeElement = Z_ARRVAL_P (stack )-> nNextFreeElement - 1 ;
@@ -3605,6 +3607,10 @@ PHP_FUNCTION(array_pop)
36053607 zend_hash_del_bucket (Z_ARRVAL_P (stack ), p );
36063608 }
36073609 zend_hash_internal_pointer_reset (Z_ARRVAL_P (stack ));
3610+
3611+ if (Z_ISREF_P (return_value )) {
3612+ zend_unwrap_reference (return_value );
3613+ }
36083614}
36093615/* }}} */
36103616
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