]> granicus.if.org Git - php/commitdiff
Fixed bug #73960
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Mar 2017 20:09:36 +0000 (21:09 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 10 Mar 2017 17:20:32 +0000 (18:20 +0100)
NEWS
Zend/tests/bug73960.phpt [new file with mode: 0644]
Zend/zend_execute.h

diff --git a/NEWS b/NEWS
index 485896272f70110c452eeaf58c7642bf957e51ad..b598d4ddd00a35defb384a7f0d65c323f47506c3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Core:
   . Fixed bug #73370 (falsely exits with "Out of Memory" when using
     USE_ZEND_ALLOC=0). (Nikita)
+  . Fixed bug #73960 (Leak with instance method calling static method with
+    referenced return). (Nikita)
 
 - Date:
   . Fixed bug #72096 (Swatch time value incorrect for dates before 1970). (mcq8)
diff --git a/Zend/tests/bug73960.phpt b/Zend/tests/bug73960.phpt
new file mode 100644 (file)
index 0000000..533c87a
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #73960: Leak with instance method calling static method with referenced return
+--FILE--
+<?php
+
+$value = 'one';
+$array = array($value);
+$array = $ref =& $array;
+var_dump($array);
+
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(3) "one"
+}
index d98fe053439b5fd39d43aa51343c759de1b09375..f010f0a45d21d9294c2c0cb0f5c2f7b324aca14c 100644 (file)
@@ -79,6 +79,10 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
                                return variable_ptr;
                        }
                        if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
+                               if (value_type == IS_VAR && ref) {
+                                       ZEND_ASSERT(GC_REFCOUNT(ref) > 1);
+                                       --GC_REFCOUNT(ref);
+                               }
                                return variable_ptr;
                        }
                        garbage = Z_COUNTED_P(variable_ptr);