]> granicus.if.org Git - php/commitdiff
Fixed bug #72629 (Caught exception assignment to variables ignores references).
authorXinchen Hui <laruence@gmail.com>
Wed, 20 Jul 2016 08:59:14 +0000 (16:59 +0800)
committerXinchen Hui <laruence@gmail.com>
Wed, 20 Jul 2016 08:59:14 +0000 (16:59 +0800)
NEWS
Zend/tests/try/bug72629.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/pgsql/tests/config.inc
main/php_version.h

diff --git a/NEWS b/NEWS
index 6a42e1cf9768c49abbd62377ad2e578d279e1dbf..af9ce204ae97374b084eaa3a277ceaadaf3baab4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2016 PHP 7.0.10
 
 - Core:
+  . Fixed bug #72629 (Caught exception assignment to variables ignores
+    references). (Laruence)
   . Fixed bug #72594 (Calling an earlier instance of an included anonymous
     class fatals). (Laruence)
   . Fixed bug #72581 (previous property undefined in Exception after
diff --git a/Zend/tests/try/bug72629.phpt b/Zend/tests/try/bug72629.phpt
new file mode 100644 (file)
index 0000000..2d596c7
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #72629 (Caught exception assignment to variables ignores references)
+--FILE--
+<?php
+
+$var = null;
+$e = &$var;
+
+try {
+       throw new Exception;
+} catch (Exception $e) { }
+
+var_dump($var === $e);
+
+--EXPECT--
+bool(true)
index e73234a21cd36e1958b1d871d434a79bb5074210..3938445321660ddcce34ffe7a5d9fa7ae6ba3a40 100644 (file)
@@ -4154,6 +4154,7 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
        USE_OPLINE
        zend_class_entry *ce, *catch_ce;
        zend_object *exception;
+       zval *ex;
 
        SAVE_OPLINE();
        /* Check whether an exception has been thrown, if not, jump over code */
@@ -4188,8 +4189,11 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
        }
 
        exception = EG(exception);
-       zval_ptr_dtor(EX_VAR(opline->op2.var));
-       ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
+       ex = EX_VAR(opline->op2.var);
+       if (UNEXPECTED(Z_ISREF_P(ex))) {
+               ex = Z_REFVAL_P(ex);
+       }
+       ZVAL_OBJ(ex, EG(exception));
        if (UNEXPECTED(EG(exception) != exception)) {
                GC_REFCOUNT(EG(exception))++;
                HANDLE_EXCEPTION();
index 04ff3ebf2ac113c4fa4fe4e6d47a0f5474c59751..08a5ae622d6ac21ec5956d701cdbf41b1a363c76 100644 (file)
@@ -9553,6 +9553,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
        USE_OPLINE
        zend_class_entry *ce, *catch_ce;
        zend_object *exception;
+       zval *ex;
 
        SAVE_OPLINE();
        /* Check whether an exception has been thrown, if not, jump over code */
@@ -9587,8 +9588,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CATCH_SPEC_CONST_CV_HANDLER(ZE
        }
 
        exception = EG(exception);
-       zval_ptr_dtor(EX_VAR(opline->op2.var));
-       ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
+       ex = EX_VAR(opline->op2.var);
+       if (UNEXPECTED(Z_ISREF_P(ex))) {
+               ex = Z_REFVAL_P(ex);
+       }
+       ZVAL_OBJ(ex, EG(exception));
        if (UNEXPECTED(EG(exception) != exception)) {
                GC_REFCOUNT(EG(exception))++;
                HANDLE_EXCEPTION();
index e9944de793cf34243f45fb30bb42fc13e35ea098..7be1e242ada488ec5b5893f598c56cdf6ef6525d 100644 (file)
@@ -5,7 +5,7 @@
 // environment var PGSQL_TEST_CONNSTR
 
 // "test" database must exist. i.e. "createdb test" before testing
-$conn_str = getenv('PGSQL_TEST_CONNSTR') ?: "host=localhost dbname=test port=5432";    // connection string
+$conn_str = getenv('PGSQL_TEST_CONNSTR') ?: "host=localhost dbname=test port=5432 user=postgres password=postgres";    // connection string
 
 $table_name      = "php_pgsql_test";          // test table that will be created
 $table_name_92   = "php_pgsql_test_92";       // test table that will be created
index b69e1adadaae2f74ee8386b4a10ccedcbab9901a..00021c119bf38a74d33d4e8f307de8a620bcc46a 100644 (file)
@@ -2,7 +2,7 @@
 /* edit configure.in to change version number */
 #define PHP_MAJOR_VERSION 7
 #define PHP_MINOR_VERSION 0
-#define PHP_RELEASE_VERSION 10
+#define PHP_RELEASE_VERSION 7
 #define PHP_EXTRA_VERSION "-dev"
-#define PHP_VERSION "7.0.10-dev"
-#define PHP_VERSION_ID 70010
+#define PHP_VERSION "7.0.7-dev"
+#define PHP_VERSION_ID 70007