]> granicus.if.org Git - php/commitdiff
Fix leak on assign concat of array and empty string
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 31 Aug 2020 15:03:27 +0000 (17:03 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 31 Aug 2020 15:05:31 +0000 (17:05 +0200)
Zend/tests/assign_concat_array_empty_string.phpt [new file with mode: 0644]
Zend/zend_operators.c

diff --git a/Zend/tests/assign_concat_array_empty_string.phpt b/Zend/tests/assign_concat_array_empty_string.phpt
new file mode 100644 (file)
index 0000000..fcacb60
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Assign concat of array and empty string
+--FILE--
+<?php
+
+$a = [0];
+$a .= '';
+var_dump($a);
+
+?>
+--EXPECTF--
+Notice: Array to string conversion in %s on line %d
+string(5) "Array"
index ef778ea100b81cbb49c975a2a8283f5975410431..45cdc1b11c9081afc4c64efbcfc4e6cf07f73a75 100644 (file)
@@ -1836,6 +1836,9 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /
                }
        } else if (UNEXPECTED(Z_STRLEN_P(op2) == 0)) {
                if (EXPECTED(result != op1)) {
+                       if (result == orig_op1) {
+                               i_zval_ptr_dtor(result ZEND_FILE_LINE_CC);
+                       }
                        ZVAL_COPY(result, op1);
                }
        } else {