From: Sara Golemon Date: Thu, 29 Jul 2004 16:36:00 +0000 (+0000) Subject: Plug some memory leaks and promote unknown label to E_ERROR. X-Git-Tag: PRE_ZEND_VM_DISPATCH_PATCH~316 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c844fdde39826b4d1b3c65c03bf1ff9c0e94d6b;p=php Plug some memory leaks and promote unknown label to E_ERROR. If someone tries to jump to a non-existant label execution really shouldn't try to carry on. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 0c0a227e8c..623d78f869 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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"); } diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 14b2514c18..0b756ee402 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -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(); }