]> granicus.if.org Git - php/commitdiff
Plug some memory leaks and promote unknown label to E_ERROR.
authorSara Golemon <pollita@php.net>
Thu, 29 Jul 2004 16:36:00 +0000 (16:36 +0000)
committerSara Golemon <pollita@php.net>
Thu, 29 Jul 2004 16:36:00 +0000 (16:36 +0000)
If someone tries to jump to a non-existant label execution really
shouldn't try to carry on.

Zend/zend_compile.c
Zend/zend_execute.c

index 0c0a227e8c4cf2999b0340b976019b36f077e079..623d78f869168f835215799ba9e287901d60b7b3 100644 (file)
@@ -3506,7 +3506,8 @@ void zend_do_label(znode *label TSRMLS_DC)
        SET_UNUSED(opline->op1);
        SET_UNUSED(opline->op2);
 
-       if (label->op_type == IS_CONST) {
+       if (label->op_type == IS_CONST &&
+               label->u.constant.type == IS_STRING) {
                if (!CG(active_op_array)->labels) {
                        CG(active_op_array)->labels = emalloc(sizeof(HashTable));
                        zend_hash_init(CG(active_op_array)->labels, 16, NULL, NULL, 0);
@@ -3517,6 +3518,7 @@ void zend_do_label(znode *label TSRMLS_DC)
                        /* Point to our newly created NOP instruction */
                        zend_hash_add(CG(active_op_array)->labels, label->u.constant.value.str.val, label->u.constant.value.str.len + 1, &opline, sizeof(zend_op*), NULL);
                }
+               zval_dtor(&label->u.constant);
        } else {
                zend_error(E_COMPILE_ERROR, "Invalid label identifier, expecting T_STRING");
        }
index 14b2514c1853b8084da5cdfdfee71f1a82cb96fc..0b756ee40290506d01c08b67ac54b8f8e5cac52a 100644 (file)
@@ -4080,11 +4080,13 @@ int zend_goto_handler(ZEND_OPCODE_HANDLER_ARGS)
 #if DEBUG_ZEND>=2
                printf("Jumping on goto to opcode %08X\n", *target);
 #endif
+               zval_dtor(&tmp);
                SET_OPCODE(*target);
                return 0;
        }
 
-       zend_error(E_WARNING, "Unknown label %s", Z_STRVAL_P(label));
+       zval_dtor(&tmp);
+       zend_error(E_ERROR, "Unknown label %s", Z_STRVAL_P(label));
        NEXT_OPCODE();
 }