@@ -4837,16 +4837,12 @@ PHP_FUNCTION(strip_tags)
48374837}
48384838/* }}} */
48394839
4840- static zend_string * try_setlocale_str (zend_long cat , zend_string * loc , uint32_t arg_num ) {
4840+ static zend_string * try_setlocale_str (zend_long cat , zend_string * loc ) {
48414841 const char * retval ;
48424842
48434843 if (zend_string_equals_literal (loc , "0" )) {
48444844 loc = NULL ;
48454845 } else {
4846- if (zend_str_has_nul_byte (loc )) {
4847- zend_argument_value_error (arg_num , "must not contain any null bytes" );
4848- return NULL ;
4849- }
48504846 if (ZSTR_LEN (loc ) >= 255 ) {
48514847 php_error_docref (NULL , E_WARNING , "Specified locale name is too long" );
48524848 return NULL ;
@@ -4907,13 +4903,18 @@ static zend_string *try_setlocale_str(zend_long cat, zend_string *loc, uint32_t
49074903 return zend_string_init (retval , strlen (retval ), 0 );
49084904}
49094905
4910- static zend_string * try_setlocale_zval (zend_long cat , zval * loc_zv , uint32_t arg_num ) {
4906+ static zend_string * try_setlocale_zval (zend_long cat , zval * loc_zv ) {
49114907 zend_string * tmp_loc_str ;
49124908 zend_string * loc_str = zval_try_get_tmp_string (loc_zv , & tmp_loc_str );
49134909 if (UNEXPECTED (loc_str == NULL )) {
49144910 return NULL ;
49154911 }
4916- zend_string * result = try_setlocale_str (cat , loc_str , arg_num );
4912+ if (zend_str_has_nul_byte (loc_str )) {
4913+ zend_argument_value_error (2 , "must not contain any null bytes" );
4914+ zend_tmp_string_release (tmp_loc_str );
4915+ return NULL ;
4916+ }
4917+ zend_string * result = try_setlocale_str (cat , loc_str );
49174918 zend_tmp_string_release (tmp_loc_str );
49184919 return result ;
49194920}
@@ -4934,8 +4935,11 @@ PHP_FUNCTION(setlocale)
49344935 zend_string * * strings = do_alloca (sizeof (zend_string * ) * num_args , use_heap );
49354936
49364937 for (uint32_t i = 0 ; i < num_args ; i ++ ) {
4937- if (UNEXPECTED (Z_TYPE (args [i ]) != IS_ARRAY && !zend_parse_arg_str (& args [i ], & strings [i ], true, i + 2 ))) {
4938- zend_wrong_parameter_type_error (i + 2 , Z_EXPECTED_ARRAY_OR_STRING_OR_NULL , & args [i ]);
4938+ if (UNEXPECTED (Z_TYPE (args [i ]) != IS_ARRAY && !zend_parse_arg_path_str (& args [i ], & strings [i ], true, i + 2 ))) {
4939+ zend_wrong_parameter_type_error (
4940+ i + 2 ,
4941+ Z_TYPE (args [i ]) == IS_STRING ? Z_EXPECTED_PATH : Z_EXPECTED_ARRAY_OR_STRING_OR_NULL ,
4942+ & args [i ]);
49394943 goto out ;
49404944 }
49414945 }
@@ -4945,7 +4949,7 @@ PHP_FUNCTION(setlocale)
49454949 if (Z_TYPE (args [i ]) == IS_ARRAY ) {
49464950 zval * elem ;
49474951 ZEND_HASH_FOREACH_VAL (Z_ARRVAL (args [i ]), elem ) {
4948- result = try_setlocale_zval (cat , elem , i + 2 );
4952+ result = try_setlocale_zval (cat , elem );
49494953 if (EG (exception )) {
49504954 goto out ;
49514955 }
@@ -4956,9 +4960,9 @@ PHP_FUNCTION(setlocale)
49564960 } ZEND_HASH_FOREACH_END ();
49574961 continue ;
49584962 } else if (Z_ISNULL (args [i ])) {
4959- result = try_setlocale_str (cat , ZSTR_EMPTY_ALLOC (), i + 2 );
4963+ result = try_setlocale_str (cat , ZSTR_EMPTY_ALLOC ());
49604964 } else {
4961- result = try_setlocale_str (cat , strings [i ], i + 2 );
4965+ result = try_setlocale_str (cat , strings [i ]);
49624966 }
49634967 if (EG (exception )) {
49644968 goto out ;
0 commit comments