mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix leak when yielding array as key
The code was copy-pasted and I forgot to change OP1 to OP2 in that one place.
This commit is contained in:
parent
1b5b839312
commit
dffffdeb3d
3 changed files with 27 additions and 9 deletions
18
Zend/tests/generators/yield_array_key.phpt
Normal file
18
Zend/tests/generators/yield_array_key.phpt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
--TEST--
|
||||||
|
Array keys can be yielded from generators
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function gen() {
|
||||||
|
yield [] => 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$gen = gen();
|
||||||
|
var_dump($gen->key());
|
||||||
|
var_dump($gen->current());
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
int(1)
|
|
@ -5511,7 +5511,7 @@ ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMP|VAR|CV|UNUSE
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!IS_OP1_TMP_FREE()) {
|
if (!IS_OP2_TMP_FREE()) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5005,7 +5005,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!0) {
|
if (!1) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9553,7 +9553,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!1) {
|
if (!0) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11266,7 +11266,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!1) {
|
if (!0) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11846,7 +11846,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!1) {
|
if (!0) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12537,7 +12537,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!1) {
|
if (!0) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18543,7 +18543,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!0) {
|
if (!1) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27081,7 +27081,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!0) {
|
if (!1) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35600,7 +35600,7 @@ static int ZEND_FASTCALL ZEND_YIELD_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
|
||||||
INIT_PZVAL_COPY(copy, key);
|
INIT_PZVAL_COPY(copy, key);
|
||||||
|
|
||||||
/* Temporary variables don't need ctor copying */
|
/* Temporary variables don't need ctor copying */
|
||||||
if (!0) {
|
if (!1) {
|
||||||
zval_copy_ctor(copy);
|
zval_copy_ctor(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue