From 3980b634fdcf9448c03a6004770ac5331b9ab286 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Tue, 3 Mar 2009 11:46:20 +0000 Subject: [PATCH] Fixed bug #47546 (Default value for limit parameter in explode is 0, not -1) --- ext/standard/string.c | 2 +- ext/standard/tests/strings/bug47546.phpt | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/strings/bug47546.phpt diff --git a/ext/standard/string.c b/ext/standard/string.c index 7806a8107b..c0b37aae20 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1311,7 +1311,7 @@ PHP_FUNCTION(explode) } else { add_index_stringl(return_value, 0, (char *)str, str_len, 1); } - } else if (limit < 0 && argc == 3) { + } else if (limit < -1 && argc == 3) { if ( str_type == IS_UNICODE ) { php_u_explode_negative_limit((UChar *)delim, delim_len, (UChar *)str, str_len, return_value, limit); } else { 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 +) -- 2.40.0