From: Ilia Alshanetsky Date: Wed, 11 Oct 2006 14:30:50 +0000 (+0000) Subject: MFB: Catch empty strings right away. X-Git-Tag: RELEASE_1_0_0RC1~1312 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fa1fb9db33f984ca407f99232cd6feb9f5f539e;p=php MFB: Catch empty strings right away. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 5a67d861c1..126ec0d561 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -7478,16 +7478,22 @@ PHP_FUNCTION(str_word_count) } switch (type) { - case 1: - case 2: - array_init(return_value); - break; - case 0: - /* nothing to be done */ - break; - default: + case 1: + case 2: + array_init(return_value); + if (!str_len) { + return; + } + break; + case 0: + if (!str_len) { + RETURN_LONG(0); + } + break; + default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format value %ld", type); RETURN_FALSE; + break; } if (str_type == IS_UNICODE) {