Skip to content

Commit 7fc0493

Browse files
nikicsmalyshev
authored andcommitted
Fixed bug #69892
1 parent 8f1baa6 commit 7fc0493

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2015 PHP 5.4.44
44

5+
. Fixed bug #69892 (Different arrays compare indentical due to integer key
6+
truncation). (Nikita)
7+
58
09 Jul 2015 PHP 5.4.43
69

710
- Core:

Zend/tests/bug69892.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #69892: Different arrays compare indentical due to integer key truncation
3+
--SKIPIF--
4+
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?>
5+
--FILE--
6+
<?php
7+
var_dump([0 => 0] === [0x100000000 => 0]);
8+
?>
9+
--EXPECT--
10+
bool(false)

Zend/zend_hash.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,11 +1513,10 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
15131513
}
15141514
if (ordered) {
15151515
if (p1->nKeyLength==0 && p2->nKeyLength==0) { /* numeric indices */
1516-
result = p1->h - p2->h;
1517-
if (result!=0) {
1516+
if (p1->h != p2->h) {
15181517
HASH_UNPROTECT_RECURSION(ht1);
15191518
HASH_UNPROTECT_RECURSION(ht2);
1520-
return result;
1519+
return p1->h > p2->h ? 1 : -1;
15211520
}
15221521
} else { /* string indices */
15231522
result = p1->nKeyLength - p2->nKeyLength;

0 commit comments

Comments
 (0)