mirror of
https://github.com/php/php-src.git
synced 2024-12-04 07:14:10 +08:00
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.
This commit is contained in:
parent
5865b3680a
commit
8c844fdde3
@ -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");
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user