From: Antony Dovgal Date: Thu, 8 Mar 2007 00:43:06 +0000 (+0000) Subject: fix #40752 (parse_ini_file() segfaults when a scalar setting is redeclared as an... X-Git-Tag: RELEASE_1_0_1~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebb2fc5b1b0a996602504f4419c9aa4541589569;p=php fix #40752 (parse_ini_file() segfaults when a scalar setting is redeclared as an array) --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 582cf38cb6..2dc28e4c22 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -6211,6 +6211,12 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, } } + if (Z_TYPE_P(hash) != IS_ARRAY) { + zval_dtor(hash); + INIT_PZVAL(hash); + array_init(hash); + } + ALLOC_ZVAL(element); *element = *arg2; zval_copy_ctor(element); diff --git a/ext/standard/tests/general_functions/bug40752.phpt b/ext/standard/tests/general_functions/bug40752.phpt new file mode 100644 index 0000000000..67daee906d --- /dev/null +++ b/ext/standard/tests/general_functions/bug40752.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #40752 (parse_ini_file() segfaults when a scalar setting is redeclared as an array) +--FILE-- + +--EXPECTF-- +array(1) { + ["foo"]=> + array(1) { + [0]=> + string(1) "1" + } +} +array(1) { + ["foo"]=> + string(1) "1" +} +Done +--UEXPECTF-- +array(1) { + [u"foo"]=> + array(1) { + [0]=> + unicode(1) "1" + } +} +array(1) { + [u"foo"]=> + unicode(1) "1" +} +Done