Skip to content

Commit

Permalink
Fix leak on assign concat of array and empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Aug 31, 2020
1 parent 488e53c commit cd2afd9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Zend/tests/assign_concat_array_empty_string.phpt
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions Zend/zend_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cd2afd9

Please sign in to comment.