Skip to content

Instantly share code, notes, and snippets.

@cmb69

cmb69/.diff Secret

Created January 23, 2022 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmb69/69937eeeefbcd37360a891256500bf4c to your computer and use it in GitHub Desktop.
Save cmb69/69937eeeefbcd37360a891256500bf4c to your computer and use it in GitHub Desktop.
quick fix for array_diff_uassoc() (https://3v4l.org/GWoNH)
ext/standard/array.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ext/standard/array.c b/ext/standard/array.c
index aa89e3755b..4f9d3e54f0 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -5320,6 +5320,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
ptrs[i]++;
}
} else if (behavior & DIFF_ASSOC) { /* triggered also when DIFF_KEY */
+more:
while (Z_TYPE(ptr->val) != IS_UNDEF && (0 != (c = diff_key_compare_func(ptrs[0], ptr)))) {
ptr++;
}
@@ -5345,6 +5346,8 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
BG(user_compare_fci) = *fci_key;
BG(user_compare_fci_cache) = *fci_key_cache;
}
+ ptr++;
+ goto more;
} else {
break;
/* we have found the element in other arrays thus we don't want it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment