Skip to content

Commit d71f859

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 247d561 + 91c4abc commit d71f859

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Zend/tests/pow_array_leak.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Memory leak on ** with result==op1 array
3+
--FILE--
4+
<?php
5+
6+
$x = [0];
7+
$x **= 1;
8+
var_dump($x);
9+
10+
$x = [0];
11+
$x **= $x;
12+
var_dump($x);
13+
14+
?>
15+
--EXPECT--
16+
int(0)
17+
int(0)

Zend/zend_operators.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,19 +1224,28 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {
12241224

12251225
if (EXPECTED(op1 != op2)) {
12261226
if (Z_TYPE_P(op1) == IS_ARRAY) {
1227+
if (op1 == result) {
1228+
zval_ptr_dtor(result);
1229+
}
12271230
ZVAL_LONG(result, 0);
12281231
return SUCCESS;
12291232
} else {
12301233
op1 = zendi_convert_scalar_to_number(op1, &op1_copy, result, 0);
12311234
}
12321235
if (Z_TYPE_P(op2) == IS_ARRAY) {
1236+
if (op1 == result) {
1237+
zval_ptr_dtor(result);
1238+
}
12331239
ZVAL_LONG(result, 1L);
12341240
return SUCCESS;
12351241
} else {
12361242
op2 = zendi_convert_scalar_to_number(op2, &op2_copy, result, 0);
12371243
}
12381244
} else {
12391245
if (Z_TYPE_P(op1) == IS_ARRAY) {
1246+
if (op1 == result) {
1247+
zval_ptr_dtor(result);
1248+
}
12401249
ZVAL_LONG(result, 0);
12411250
return SUCCESS;
12421251
} else {

0 commit comments

Comments
 (0)