Skip to content

Commit 5d33024

Browse files
committed
Fixed bug #77439
1 parent 7a88f89 commit 5d33024

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ PHP NEWS
2222

2323
- Standard:
2424
. Fixed bug #77395 (segfault about array_multisort). (Laruence)
25+
. Fixed bug #77439 (parse_str segfaults when inserting item into existing
26+
array). (Nikita)
2527

2628
10 Jan 2019, PHP 7.2.14
2729

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #77439: parse_str segfaults when inserting item into existing array
3+
--FILE--
4+
<?php
5+
$a = [];
6+
parse_str('a[1]=1');
7+
var_dump($a);
8+
?>
9+
--EXPECTF--
10+
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
11+
array(1) {
12+
[1]=>
13+
string(1) "1"
14+
}

main/php_variables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
218218
if (Z_TYPE_P(gpc_element_p) != IS_ARRAY) {
219219
zval_ptr_dtor(gpc_element_p);
220220
array_init(gpc_element_p);
221+
} else {
222+
SEPARATE_ARRAY(gpc_element_p);
221223
}
222224
}
223225
}

0 commit comments

Comments
 (0)