]> granicus.if.org Git - php/commitdiff
Fixed bug #70240 (Segfault when doing unset($var());)
authorXinchen Hui <laruence@php.net>
Tue, 11 Aug 2015 13:42:11 +0000 (21:42 +0800)
committerXinchen Hui <laruence@php.net>
Tue, 11 Aug 2015 13:42:11 +0000 (21:42 +0800)
NEWS
Zend/tests/bug70240.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index 2a6eda99b43f2d40bcb480ca9cc63845825c4be7..9437c0f440af3f4eb5c95670cf21b3dd58beb869 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 20 Aug 2015, PHP 7.0.0 RC 1
 
 - Core:
+  . Fixed bug #70240 (Segfault when doing unset($var());). (Laruence)
   . Fixed bug #70223 (Incrementing value returned by magic getter). (Laruence)
   . Fixed bug #70215 (Segfault when __invoke is static). (Bob)
   . Fixed bug #70207 (Finally is broken with opcache). (Laruence, Dmitry)
diff --git a/Zend/tests/bug70240.phpt b/Zend/tests/bug70240.phpt
new file mode 100644 (file)
index 0000000..d2aae21
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Bug #70240 (Segfault when doing unset($var()))
+--FILE--
+<?php
+unset($var());
+?>
+--EXPECTF--
+Fatal error: Can't use function return value in write context in %sbug70240.php on line %d
index c669c1f5cc02b5ee2f1f4261613508a387043879..606775a11ac03c28f2f179dd65138dbcd95fb59b 100644 (file)
@@ -3428,9 +3428,11 @@ void zend_compile_static_var(zend_ast *ast) /* {{{ */
 void zend_compile_unset(zend_ast *ast) /* {{{ */
 {
        zend_ast *var_ast = ast->child[0];
-
        znode var_node;
        zend_op *opline;
+
+       zend_ensure_writable_variable(var_ast);
+
        switch (var_ast->kind) {
                case ZEND_AST_VAR:
                        if (zend_try_compile_cv(&var_node, var_ast) == SUCCESS) {