diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-31 17:05:44 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-31 17:05:55 +0200 |
commit | 9560e3ba7ab64e3fb9815253e33095d11e83e978 (patch) | |
tree | 5392767708653ce439671200f89129ec42ba1f7f | |
parent | 1f6f9c70cb4e82ca9fbbf3153173e3d73a0f9170 (diff) | |
parent | cd2afd99b1faa58c35a3807081e531cce0cd2311 (diff) | |
download | php-git-9560e3ba7ab64e3fb9815253e33095d11e83e978.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
Fix leak on assign concat of array and empty string
-rw-r--r-- | Zend/tests/assign_concat_array_empty_string.phpt | 13 | ||||
-rw-r--r-- | Zend/zend_operators.c | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Zend/tests/assign_concat_array_empty_string.phpt b/Zend/tests/assign_concat_array_empty_string.phpt new file mode 100644 index 0000000000..fcacb60675 --- /dev/null +++ b/Zend/tests/assign_concat_array_empty_string.phpt @@ -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" diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 656316cc4e..08fc18f261 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1871,6 +1871,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); + } ZVAL_COPY(result, op1); } } else { |