com php-src: Fixed segfault with empty break: Zend/tests/try_ finally_011.phpt Zend/zend_opcode.c
| From: | Xinchen Hui | Date: | Sat, 19 Jul 2014 07:30:50 +0000 |
| Subject: | com php-src: Fixed segfault with empty break: Zend/tests/try_ finally_011.phpt Zend/zend_opcode.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79524@lists.php.net to get a copy of this message | ||
Commit: 9ce1a36af2295a75e4244eac3085f82d0c25105d
Author: Xinchen Hui <laruence@php.net> Sat, 19 Jul 2014 15:30:50 +0800
Parents: 629c1ecd4f6576f801e346de8c593bde116c9372
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9ce1a36af2295a75e4244eac3085f82d0c25105d
Log:
Fixed segfault with empty break
Changed paths:
A Zend/tests/try_finally_011.phpt
M Zend/zend_opcode.c
Diff:
diff --git a/Zend/tests/try_finally_011.phpt b/Zend/tests/try_finally_011.phpt
new file mode 100644
index 0000000..7aa3f35
--- /dev/null
+++ b/Zend/tests/try_finally_011.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Try finally (segfault with empty break)
+--FILE--
+<?php
+function foo () {
+ try {
+ break;
+ } finally {
+ }
+}
+
+foo();
+?>
+--EXPECTF--
+Fatal error: Cannot break/continue 1 level in %stry_finally_011.php on line %d
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 80ec632..b3fb11f 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -643,15 +643,16 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC)
zend_brk_cont_element *jmp_to;
nest_levels = Z_LVAL(op_array->literals[opline->op2.constant].constant);
- array_offset = opline->op1.opline_num;
- do {
- jmp_to = &op_array->brk_cont_array[array_offset];
- if (nest_levels > 1) {
- array_offset = jmp_to->parent;
- }
- } while (--nest_levels > 0);
- zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk :
jmp_to->cont TSRMLS_CC);
- break;
+ if ((array_offset = opline->op1.opline_num) != -1) {
+ do {
+ jmp_to = &op_array->brk_cont_array[array_offset];
+ if (nest_levels > 1) {
+ array_offset = jmp_to->parent;
+ }
+ } while (--nest_levels > 0);
+ zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk :
jmp_to->cont TSRMLS_CC);
+ break;
+ }
}
case ZEND_GOTO:
if (Z_TYPE(op_array->literals[opline->op2.constant].constant) != IS_LONG) {