Skip to content

Commit 47f9014

Browse files
committed
Fixed array_nultisort() to support IS_REFERENCE
1 parent 84c092f commit 47f9014

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ext/standard/array.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,7 +3860,12 @@ PHP_FUNCTION(array_multisort)
38603860
* accordingly. There can't be two sort flags of the same type after an
38613861
* array, and the very first argument has to be an array. */
38623862
for (i = 0; i < argc; i++) {
3863-
if (Z_TYPE(args[i]) == IS_ARRAY) {
3863+
zval *arg = &args[i];
3864+
3865+
if (Z_TYPE_P(arg) == IS_REFERENCE) {
3866+
arg = Z_REFVAL_P(arg);
3867+
}
3868+
if (Z_TYPE_P(arg) == IS_ARRAY) {
38643869
/* We see the next array, so we update the sort flags of
38653870
* the previous array and reset the sort flags. */
38663871
if (i > 0) {
@@ -3869,14 +3874,14 @@ PHP_FUNCTION(array_multisort)
38693874
sort_order = PHP_SORT_ASC;
38703875
sort_type = PHP_SORT_REGULAR;
38713876
}
3872-
arrays[num_arrays++] = &args[i];
3877+
arrays[num_arrays++] = arg;
38733878

38743879
/* Next one may be an array or a list of sort flags. */
38753880
for (k = 0; k < MULTISORT_LAST; k++) {
38763881
parse_state[k] = 1;
38773882
}
3878-
} else if (Z_TYPE(args[i]) == IS_LONG) {
3879-
switch (Z_LVAL(args[i]) & ~PHP_SORT_FLAG_CASE) {
3883+
} else if (Z_TYPE_P(arg) == IS_LONG) {
3884+
switch (Z_LVAL_P(arg) & ~PHP_SORT_FLAG_CASE) {
38803885
case PHP_SORT_ASC:
38813886
case PHP_SORT_DESC:
38823887
/* flag allowed here */

0 commit comments

Comments
 (0)