From: Kalle Sommer Nielsen Date: Tue, 3 Mar 2009 11:50:32 +0000 (+0000) Subject: MFH: Fixed bug #47546 (Default value for limit parameter in explode is 0, not -1) X-Git-Tag: php-5.2.10RC1~309 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d8283a3ad6e1bac8f20418da62573c0d7d5c2c0;p=php MFH: Fixed bug #47546 (Default value for limit parameter in explode is 0, not -1) --- diff --git a/NEWS b/NEWS index 013c32d0cf..7fb5768e31 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2009, PHP 5.2.10 - Fixed memory corruptions while reading properties of zip files. (Ilia) +- Fixed bug #47546 (Default value for limit parameter in explode is 0, + not -1). (Kalle) - Fixed bug #47435 (FILTER_FLAG_NO_PRIV_RANGE does not work with ipv6 addresses in the filter extension). (Ilia) diff --git a/ext/standard/string.c b/ext/standard/string.c index 0311caa2d5..9925b89add 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1042,7 +1042,7 @@ PHP_FUNCTION(explode) if (limit == 0 || limit == 1) { add_index_stringl(return_value, 0, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1); - } else if (limit < 0 && argc == 3) { + } else if (limit < -1 && argc == 3) { php_explode_negative_limit(*delim, *str, return_value, limit); } else { php_explode(*delim, *str, return_value, limit); diff --git a/ext/standard/tests/strings/bug47546.phpt b/ext/standard/tests/strings/bug47546.phpt new file mode 100644 index 0000000000..f04f9be05a --- /dev/null +++ b/ext/standard/tests/strings/bug47546.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #47546 (Default value for limit parameter in explode is 0, not -1) +--FILE-- + +--EXPECT-- +Array +( + [0] => one + [1] => two + [2] => three + [3] => four +) +Array +( + [0] => one + [1] => two + [2] => three + [3] => four +)