From: Antony Dovgal Date: Wed, 26 Mar 2008 09:09:08 +0000 (+0000) Subject: allow NULL argument to be passed where binary string expected X-Git-Tag: RELEASE_2_0_0a2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2ca4aaf6a192287a759cbd905da3bdccb1f0b71;p=php allow NULL argument to be passed where binary string expected --- diff --git a/Zend/tests/null_argument_001.phpt b/Zend/tests/null_argument_001.phpt new file mode 100644 index 0000000000..9a5c707151 --- /dev/null +++ b/Zend/tests/null_argument_001.phpt @@ -0,0 +1,52 @@ +--TEST-- +NULL argument is allowed where binary string expected +--FILE-- + +--EXPECTF-- +string(0) "" +string(0) "" +string(0) "" + +Warning: urldecode() expects parameter 1 to be string, array given in %s on line %d +NULL +string(1) "1" +string(0) "" + +Warning: urldecode() expects parameter 1 to be string, object given in %s on line %d +NULL + +Warning: urldecode() expects parameter 1 to be string, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +string(0) "" +string(0) "" + +Warning: urldecode() expects parameter 1 to be strictly a binary string, Unicode string given in %s on line %d +NULL + +Warning: urldecode() expects parameter 1 to be binary string, array given in %s on line %d +NULL +string(1) "1" +string(0) "" + +Warning: urldecode() expects parameter 1 to be binary string, object given in %s on line %d +NULL + +Warning: urldecode() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +Done diff --git a/Zend/zend_API.c b/Zend/zend_API.c index d20439f70a..c386b66513 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -476,7 +476,7 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp *p = Z_STRVAL_PP(arg); *pl = Z_STRLEN_PP(arg); break; - } else if (c == 'S') { + } else if (c == 'S' && Z_TYPE_PP(arg) != IS_NULL /* NULL is ok */) { return "strictly a binary string"; } /* fall through */