Skip to content

Commit d84ef96

Browse files
committed
SEND_UNPACK should throw exception on Traversable with non-integer keys
1 parent a6467af commit d84ef96

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Zend/zend_vm_def.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4521,14 +4521,13 @@ ZEND_VM_C_LABEL(send_again):
45214521
break;
45224522
}
45234523

4524-
if (Z_TYPE(key) == IS_STRING) {
4524+
if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
4525+
ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
45254526
zend_throw_error(NULL,
45264527
"Cannot unpack Traversable with string keys");
45274528
zend_string_release_ex(Z_STR(key), 0);
45284529
break;
45294530
}
4530-
4531-
zval_dtor(&key);
45324531
}
45334532

45344533
if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {

Zend/zend_vm_execute.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,14 +1358,13 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_
13581358
break;
13591359
}
13601360

1361-
if (Z_TYPE(key) == IS_STRING) {
1361+
if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
1362+
ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
13621363
zend_throw_error(NULL,
13631364
"Cannot unpack Traversable with string keys");
13641365
zend_string_release_ex(Z_STR(key), 0);
13651366
break;
13661367
}
1367-
1368-
zval_dtor(&key);
13691368
}
13701369

13711370
if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {

0 commit comments

Comments
 (0)