Skip to content

Commit 91c4abc

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 99c6780 + ab938d7 commit 91c4abc

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
@@ -1193,19 +1193,28 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {
11931193

11941194
if (EXPECTED(op1 != op2)) {
11951195
if (Z_TYPE_P(op1) == IS_ARRAY) {
1196+
if (op1 == result) {
1197+
zval_ptr_dtor(result);
1198+
}
11961199
ZVAL_LONG(result, 0);
11971200
return SUCCESS;
11981201
} else {
11991202
op1 = zendi_convert_scalar_to_number(op1, &op1_copy, result, 0);
12001203
}
12011204
if (Z_TYPE_P(op2) == IS_ARRAY) {
1205+
if (op1 == result) {
1206+
zval_ptr_dtor(result);
1207+
}
12021208
ZVAL_LONG(result, 1L);
12031209
return SUCCESS;
12041210
} else {
12051211
op2 = zendi_convert_scalar_to_number(op2, &op2_copy, result, 0);
12061212
}
12071213
} else {
12081214
if (Z_TYPE_P(op1) == IS_ARRAY) {
1215+
if (op1 == result) {
1216+
zval_ptr_dtor(result);
1217+
}
12091218
ZVAL_LONG(result, 0);
12101219
return SUCCESS;
12111220
} else {

0 commit comments

Comments
 (0)