@@ -4916,6 +4916,12 @@ PHP_FUNCTION(array_unique)
49164916
49174917 cmp = php_get_data_compare_func_unstable (sort_type , false);
49184918
4919+ if (cmp == NULL ){
4920+ zend_argument_value_error (
4921+ 2 , "must be one of SORT_REGULAR, SORT_NUMERIC, SORT_STRING, or SORT_LOCALE_STRING" );
4922+ RETURN_THROWS ();
4923+ }
4924+
49194925 bool in_place = zend_may_modify_arg_in_place (array );
49204926 if (in_place ) {
49214927 RETVAL_ARR (Z_ARRVAL_P (array ));
@@ -5990,7 +5996,20 @@ PHP_FUNCTION(array_multisort)
59905996 /* We see the next array, so we update the sort flags of
59915997 * the previous array and reset the sort flags. */
59925998 if (i > 0 ) {
5993- func [num_arrays - 1 ] = php_get_data_compare_func_unstable (sort_type , sort_order != PHP_SORT_ASC );
5999+ bucket_compare_func_t cmp =
6000+ php_get_data_compare_func_unstable (
6001+ sort_type , sort_order != PHP_SORT_ASC
6002+ );
6003+
6004+ if (cmp == NULL ) {
6005+ zend_argument_value_error (
6006+ 2 ,
6007+ "must be one of SORT_REGULAR, SORT_NUMERIC, SORT_STRING, or SORT_LOCALE_STRING"
6008+ );
6009+ RETURN_THROWS ();
6010+ }
6011+
6012+ func [num_arrays - 1 ] = cmp ;
59946013 sort_order = PHP_SORT_ASC ;
59956014 sort_type = PHP_SORT_REGULAR ;
59966015 }
@@ -6060,7 +6079,20 @@ PHP_FUNCTION(array_multisort)
60606079 }
60616080
60626081 /* Take care of the last array sort flags. */
6063- func [num_arrays - 1 ] = php_get_data_compare_func_unstable (sort_type , sort_order != PHP_SORT_ASC );
6082+ bucket_compare_func_t cmp =
6083+ php_get_data_compare_func_unstable (
6084+ sort_type , sort_order != PHP_SORT_ASC
6085+ );
6086+
6087+ if (cmp == NULL ) {
6088+ zend_argument_value_error (
6089+ 2 ,
6090+ "must be one of SORT_REGULAR, SORT_NUMERIC, SORT_STRING, or SORT_LOCALE_STRING"
6091+ );
6092+ RETURN_THROWS ();
6093+ }
6094+
6095+ func [num_arrays - 1 ] = cmp ;
60646096 bucket_compare_func_t * old_multisort_func = ARRAYG (multisort_func );
60656097 ARRAYG (multisort_func ) = func ;
60666098
0 commit comments