@@ -4903,14 +4903,14 @@ static zend_string *try_setlocale_str(zend_long cat, zend_string *loc) {
49034903 return zend_string_init (retval , strlen (retval ), 0 );
49044904}
49054905
4906- 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 ) {
49074907 zend_string * tmp_loc_str ;
49084908 zend_string * loc_str = zval_try_get_tmp_string (loc_zv , & tmp_loc_str );
49094909 if (UNEXPECTED (loc_str == NULL )) {
49104910 return NULL ;
49114911 }
49124912 if (zend_str_has_nul_byte (loc_str )) {
4913- zend_argument_value_error (arg_num , "must not contain any null bytes" );
4913+ zend_argument_value_error (2 , "must not contain any null bytes" );
49144914 zend_tmp_string_release (tmp_loc_str );
49154915 return NULL ;
49164916 }
@@ -4940,6 +4940,12 @@ PHP_FUNCTION(setlocale)
49404940 zend_wrong_parameter_type_error (i + 2 , Z_EXPECTED_STRING_OR_NULL , & args [i ]);
49414941 goto out ;
49424942 }
4943+ if (UNEXPECTED (num_args > 1 )) {
4944+ zend_argument_count_error (
4945+ "setlocale() expects exactly 2 arguments when argument #2 ($locales) is an array, %d given" ,
4946+ ZEND_NUM_ARGS ());
4947+ goto out ;
4948+ }
49434949 num_args = 1 ;
49444950 break ;
49454951 }
@@ -4959,7 +4965,7 @@ PHP_FUNCTION(setlocale)
49594965 if (Z_TYPE (args [i ]) == IS_ARRAY ) {
49604966 zval * elem ;
49614967 ZEND_HASH_FOREACH_VAL (Z_ARRVAL (args [i ]), elem ) {
4962- result = try_setlocale_zval (cat , elem , i + 2 );
4968+ result = try_setlocale_zval (cat , elem );
49634969 if (EG (exception )) {
49644970 goto out ;
49654971 }
0 commit comments