]> granicus.if.org Git - php/commitdiff
Fixed bug #69892
authorNikita Popov <nikic@php.net>
Sat, 20 Jun 2015 14:39:23 +0000 (16:39 +0200)
committerStanislav Malyshev <stas@php.net>
Sun, 2 Aug 2015 03:47:43 +0000 (20:47 -0700)
NEWS
Zend/tests/bug69892.phpt [new file with mode: 0644]
Zend/zend_hash.c

diff --git a/NEWS b/NEWS
index ab5f07dd19911df319c150a3cd2ce1ef7d4afbf8..544346f6a2daab79a3a9b3b61424b5101f3e7ddc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2015 PHP 5.4.44
 
+. Fixed bug #69892 (Different arrays compare indentical due to integer key
+  truncation). (Nikita)
+
 09 Jul 2015 PHP 5.4.43
 
 - Core:
diff --git a/Zend/tests/bug69892.phpt b/Zend/tests/bug69892.phpt
new file mode 100644 (file)
index 0000000..d14f85f
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #69892: Different arrays compare indentical due to integer key truncation
+--SKIPIF--
+<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?>
+--FILE--
+<?php
+var_dump([0 => 0] === [0x100000000 => 0]);
+?>
+--EXPECT--
+bool(false)
index bfff87a67e3b287eab7886197f5282f801667d98..9b3fb746aff0b516422f2b392850bbbcd702048e 100644 (file)
@@ -1513,11 +1513,10 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
                }
                if (ordered) {
                        if (p1->nKeyLength==0 && p2->nKeyLength==0) { /* numeric indices */
-                               result = p1->h - p2->h;
-                               if (result!=0) {
+                               if (p1->h != p2->h) {
                                        HASH_UNPROTECT_RECURSION(ht1); 
                                        HASH_UNPROTECT_RECURSION(ht2); 
-                                       return result;
+                                       return p1->h > p2->h ? 1 : -1;
                                }
                        } else { /* string indices */
                                result = p1->nKeyLength - p2->nKeyLength;