Skip to content

Commit

Permalink
Fixed bug #77439
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jan 10, 2019
1 parent 7a88f89 commit 5d33024
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ PHP NEWS

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

10 Jan 2019, PHP 7.2.14

Expand Down
14 changes: 14 additions & 0 deletions ext/standard/tests/strings/bug77439.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Bug #77439: parse_str segfaults when inserting item into existing array
--FILE--
<?php
$a = [];
parse_str('a[1]=1');
var_dump($a);
?>
--EXPECTF--
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
array(1) {
[1]=>
string(1) "1"
}
2 changes: 2 additions & 0 deletions main/php_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
if (Z_TYPE_P(gpc_element_p) != IS_ARRAY) {
zval_ptr_dtor(gpc_element_p);
array_init(gpc_element_p);
} else {
SEPARATE_ARRAY(gpc_element_p);
}
}
}
Expand Down

0 comments on commit 5d33024

Please sign in to comment.