com php-src: Fixed bug #74444: multiple catch freezes in some cases: NEWS Zend/tests/try/bug74444.phpt Zend/zend_compile.c

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    2135b057ec33bb480a10f642a3e42ba10364b81e
Author:    David Matejka <[email protected]>         Sat, 15 Apr 2017 00:20:06 +0200
Committer: Nikita Popov <[email protected]>      Sat, 15 Apr 2017 01:38:37 +0200
Parents:   d80df7a8bf9970295f7dcb93cf56ba73a9383825
Branches:  PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=2135b057ec33bb480a10f642a3e42ba10364b81e

Log:
Fixed bug #74444: multiple catch freezes in some cases

zend_emit_jump() may reallocate, so reload the opline.

Bugs:
https://bugs.php.net/74444

Changed paths:
  M  NEWS
  A  Zend/tests/try/bug74444.phpt
  M  Zend/zend_compile.c


Diff:
diff --git a/NEWS b/NEWS
index 6af7477..c8c57be 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ PHP                                                                        NEWS
     (Nikita)
   . Fixed bug #74188 (Null coalescing operator fails for undeclared static
     class properties). (tpunt)
+  . Fixed bug #74444 (multiple catch freezes in some cases). (David Matějka)
 
 - Date:
   . Fixed bug #74404 (Wrong reflection on DateTimeZone::getTransitions).
diff --git a/Zend/tests/try/bug74444.phpt b/Zend/tests/try/bug74444.phpt
new file mode 100644
index 0000000..838d12e
--- /dev/null
+++ b/Zend/tests/try/bug74444.phpt
@@ -0,0 +1,77 @@
+--TEST--
+Bug #74444 (multiple catch freezes in some cases)
+--FILE--
+<?php
+function foo()
+{
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	echo '';
+	try {
+		throw new \RuntimeException();
+	} catch (\FooEx  | \RuntimeException $e) {
+		echo 1;
+	}
+	echo 2;
+}
+
+foo();
+
+--EXPECT--
+12
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index d1d8ddc..12e0630 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4810,6 +4810,7 @@ void zend_compile_try(zend_ast *ast) /* {{{ */
 
 			if (!is_last_class) {
 				jmp_multicatch[j] = zend_emit_jump(0);
+				opline = &CG(active_op_array)->opcodes[opnum_catch];
 				opline->extended_value = get_next_op_number(CG(active_op_array));
 			}
 		}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.