Skip to content

Commit 3c4dd73

Browse files
committed
Detect self-addition of array more accurately
While the zvals may be different, they may still point to the same array. Fixes oss-fuzz #26245.
1 parent e304468 commit 3c4dd73

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Add $GLOBALS to itself
3+
--FILE--
4+
<?php
5+
$GLOBALS += $GLOBALS;
6+
$x = $GLOBALS + $GLOBALS;
7+
?>
8+
===DONE===
9+
--EXPECT--
10+
===DONE===

Zend/zend_operators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op) /* {{{ */
903903

904904
static zend_never_inline void ZEND_FASTCALL add_function_array(zval *result, zval *op1, zval *op2) /* {{{ */
905905
{
906-
if ((result == op1) && (result == op2)) {
906+
if (result == op1 && Z_ARR_P(op1) == Z_ARR_P(op2)) {
907907
/* $a += $a */
908908
return;
909909
}

0 commit comments

Comments
 (0)