]> granicus.if.org Git - php/commitdiff
Fixed Bug #42838 (Wrong results in array_diff_uassoc)
authorFelipe Pena <felipe@php.net>
Thu, 14 Feb 2008 14:02:02 +0000 (14:02 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 14 Feb 2008 14:02:02 +0000 (14:02 +0000)
NEWS
ext/standard/array.c

diff --git a/NEWS b/NEWS
index 341693ddaa2096aac97a159ccbcbfbf872d2a68a..5655e24f868693f816e00ac321b952b05bf39f1a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -98,6 +98,7 @@ PHP                                                                        NEWS
 - Fixed bug #42937 (__call() method not invoked when methods are called on
   parent from child class). (Dmitry)
 - Fixed bug #42841 (REF CURSOR and oci_new_cursor() crash PHP). (Chris)
+- Fixed Bug #42838 (Wrong results in array_diff_uassoc) (Felipe)
 - Fixed bug #42779 (Incorrect forcing from HTTP/1.0 request to HTTP/1.1
   response). (Ilia)
 - Fixed bug #42736 (xmlrpc_server_call_method() crashes). (Tony)
index f4431ed9ebf6da11c091b9a03ebe3f2ec80936f3..4c9da9f24e30c54650ed8d79d76c6fde0de22361 100644 (file)
@@ -3718,13 +3718,14 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
                }
                c = 1;
                for (i = 1; i < arr_argc; i++) {
+                       Bucket **ptr = ptrs[i];
                        if (behavior == DIFF_NORMAL) {
-                               while (*ptrs[i] && (0 < (c = diff_data_compare_func(ptrs[0], ptrs[i] TSRMLS_CC)))) {
-                                       ptrs[i]++;
+                               while (*ptr && (0 < (c = diff_data_compare_func(ptrs[0], ptr TSRMLS_CC)))) {
+                                       ptr++;
                                }
                        } else if (behavior & DIFF_ASSOC) { /* triggered also when DIFF_KEY */
-                               while (*ptrs[i] && (0 < (c = diff_key_compare_func(ptrs[0], ptrs[i] TSRMLS_CC)))) {
-                                       ptrs[i]++;
+                               while (*ptr && (0 != (c = diff_key_compare_func(ptrs[0], ptr TSRMLS_CC)))) {
+                                       ptr++;
                                }
                        }
                        if (!c) {
@@ -3738,11 +3739,11 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
                                                In this branch is execute only when DIFF_ASSOC. If behavior == DIFF_KEY
                                                data comparison is not needed - skipped.
                                        */
-                                       if (*ptrs[i]) {
+                                       if (*ptr) {
                                                if (data_compare_type == DIFF_COMP_DATA_USER) {
                                                        BG(user_compare_func_name) = args[arr_argc];
                                                }
-                                               if (diff_data_compare_func(ptrs[0], ptrs[i] TSRMLS_CC) != 0) {
+                                               if (diff_data_compare_func(ptrs[0], ptr TSRMLS_CC) != 0) {
                                                        /* the data is not the same */
                                                        c = -1;
                                                        if (key_compare_type == DIFF_COMP_KEY_USER) {