]> granicus.if.org Git - php/commitdiff
SEND_UNPACK should throw exception on Traversable with non-integer keys
authorDmitry Stogov <dmitry@zend.com>
Wed, 4 Jul 2018 06:35:12 +0000 (09:35 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 4 Jul 2018 06:35:12 +0000 (09:35 +0300)
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 65b3f9faaf5b4ba785ba7bac404379a68556a251..095d947180945a7baa79097940773b6d9ac6ed68 100644 (file)
@@ -4521,14 +4521,13 @@ ZEND_VM_C_LABEL(send_again):
                                                break;
                                        }
 
-                                       if (Z_TYPE(key) == IS_STRING) {
+                                       if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
+                                               ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
                                                zend_throw_error(NULL,
                                                        "Cannot unpack Traversable with string keys");
                                                zend_string_release_ex(Z_STR(key), 0);
                                                break;
                                        }
-
-                                       zval_dtor(&key);
                                }
 
                                if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
index c8e198b0b6532e670075a804090a18c27b48fa6e..8220a021c20038d467c6e3fe396de568dcadc4fa 100644 (file)
@@ -1358,14 +1358,13 @@ send_again:
                                                break;
                                        }
 
-                                       if (Z_TYPE(key) == IS_STRING) {
+                                       if (UNEXPECTED(Z_TYPE(key) != IS_LONG)) {
+                                               ZEND_ASSERT(Z_TYPE(key) == IS_STRING);
                                                zend_throw_error(NULL,
                                                        "Cannot unpack Traversable with string keys");
                                                zend_string_release_ex(Z_STR(key), 0);
                                                break;
                                        }
-
-                                       zval_dtor(&key);
                                }
 
                                if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {