@@ -6051,7 +6051,7 @@ PHP_FUNCTION(array_multisort)
6051
6051
for (i = 0 ; i < MULTISORT_LAST ; i ++ ) {
6052
6052
parse_state [i ] = 0 ;
6053
6053
}
6054
- func = ARRAYG ( multisort_func ) = ecalloc (argc , sizeof (bucket_compare_func_t ));
6054
+ func = ecalloc (argc , sizeof (bucket_compare_func_t ));
6055
6055
6056
6056
/* Here we go through the input arguments and parse them. Each one can
6057
6057
* be either an array or a sort flag which follows an array. If not
@@ -6067,7 +6067,7 @@ PHP_FUNCTION(array_multisort)
6067
6067
/* We see the next array, so we update the sort flags of
6068
6068
* the previous array and reset the sort flags. */
6069
6069
if (i > 0 ) {
6070
- ARRAYG ( multisort_func ) [num_arrays - 1 ] = php_get_data_compare_func_unstable (sort_type , sort_order != PHP_SORT_ASC );
6070
+ func [num_arrays - 1 ] = php_get_data_compare_func_unstable (sort_type , sort_order != PHP_SORT_ASC );
6071
6071
sort_order = PHP_SORT_ASC ;
6072
6072
sort_type = PHP_SORT_REGULAR ;
6073
6073
}
@@ -6119,8 +6119,6 @@ PHP_FUNCTION(array_multisort)
6119
6119
MULTISORT_ABORT ;
6120
6120
}
6121
6121
}
6122
- /* Take care of the last array sort flags. */
6123
- ARRAYG (multisort_func )[num_arrays - 1 ] = php_get_data_compare_func_unstable (sort_type , sort_order != PHP_SORT_ASC );
6124
6122
6125
6123
/* Make sure the arrays are of the same size. */
6126
6124
array_size = zend_hash_num_elements (Z_ARRVAL_P (arrays [0 ]));
@@ -6138,6 +6136,11 @@ PHP_FUNCTION(array_multisort)
6138
6136
RETURN_TRUE ;
6139
6137
}
6140
6138
6139
+ /* Take care of the last array sort flags. */
6140
+ func [num_arrays - 1 ] = php_get_data_compare_func_unstable (sort_type , sort_order != PHP_SORT_ASC );
6141
+ bucket_compare_func_t * old_multisort_func = ARRAYG (multisort_func );
6142
+ ARRAYG (multisort_func ) = func ;
6143
+
6141
6144
/* Create the indirection array. This array is of size MxN, where
6142
6145
* M is the number of entries in each input array and N is the number
6143
6146
* of the input arrays + 1. The last column is UNDEF to indicate the end
@@ -6214,6 +6217,7 @@ PHP_FUNCTION(array_multisort)
6214
6217
efree (indirect );
6215
6218
efree (func );
6216
6219
efree (arrays );
6220
+ ARRAYG (multisort_func ) = old_multisort_func ;
6217
6221
}
6218
6222
/* }}} */
6219
6223
0 commit comments