]> granicus.if.org Git - php/commitdiff
Fixed incorrect compilation
authorDmitry Stogov <dmitry@zend.com>
Thu, 2 Oct 2014 09:37:44 +0000 (13:37 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 2 Oct 2014 09:37:44 +0000 (13:37 +0400)
Zend/zend_compile.c

index 41e3189dabd3c02afd65fb7321372819b4b5f87c..91bfbfeebbaa480a303f44b5026c447c08ebae1a 100644 (file)
@@ -5559,7 +5559,7 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
 {
        zend_ast_list *list = zend_ast_get_list(ast);
        zend_op *opline;
-       uint32_t i, opnum_init;
+       uint32_t i, opnum_init = -1;
        zend_bool packed = 1;
 
        if (zend_try_ct_eval_array(&result->u.constant, ast TSRMLS_CC)) {
@@ -5567,8 +5567,6 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
                return;
        }
 
-       opnum_init = get_next_op_number(CG(active_op_array));
-
        for (i = 0; i < list->children; ++i) {
                zend_ast *elem_ast = list->child[i];
                zend_ast *value_ast = elem_ast->child[0];
@@ -5591,6 +5589,7 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
                }
 
                if (i == 0) {
+                       opnum_init = get_next_op_number(CG(active_op_array));
                        opline = zend_emit_op_tmp(result, ZEND_INIT_ARRAY, &value_node, key_node_ptr TSRMLS_CC);
                        opline->extended_value = list->children << ZEND_ARRAY_SIZE_SHIFT;
                } else {
@@ -5612,6 +5611,7 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
 
        /* Add a flag to INIT_ARRAY if we know this array cannot be packed */
        if (!packed) {
+               ZEND_ASSERT(opnum_init != -1);
                opline = &CG(active_op_array)->opcodes[opnum_init];
                opline->extended_value |= ZEND_ARRAY_NOT_PACKED;
        }