]> granicus.if.org Git - php/commitdiff
Property handle read_property exception in fetch_property_address
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Aug 2020 14:10:29 +0000 (16:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 26 Aug 2020 14:12:34 +0000 (16:12 +0200)
Otherwise we leak (and corrupt uninitialized_zval).

Zend/tests/exception_during_by_reference_magic_get.phpt [new file with mode: 0644]
Zend/zend_execute.c

diff --git a/Zend/tests/exception_during_by_reference_magic_get.phpt b/Zend/tests/exception_during_by_reference_magic_get.phpt
new file mode 100644 (file)
index 0000000..5732e8c
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Exception thrown by __get() during =& assignment
+--FILE--
+<?php
+
+class Test {
+    private $x;
+    public function &__get($name) {
+        throw new Exception("Foobar");
+    }
+}
+
+$test = new Test;
+$y = 5;
+try {
+    $test->x =& $y;
+} catch (Exception $e) {
+    echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Foobar
index c5b502501e7d5dc9aef54590114dfa9494d32054..6a6ad61094ed6f3582af5e75c4911ad6c7477d2a 100644 (file)
@@ -2872,6 +2872,10 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
                        }
                        return;
                }
+               if (UNEXPECTED(EG(exception))) {
+                       ZVAL_ERROR(result);
+                       return;
+               }
        } else if (UNEXPECTED(Z_ISERROR_P(ptr))) {
                ZVAL_ERROR(result);
                return;