diff options
author | Nikita Popov <nikic@php.net> | 2015-06-20 16:39:23 +0200 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2015-08-01 20:47:43 -0700 |
commit | 7fc04937f5ba48e05d311937477ba81b0e07ffa8 (patch) | |
tree | b38c15887d11a3d8d5e85613f7b00175a6fce21c | |
parent | 8f1baa6e1ceffb54529402e210e6397466e1049a (diff) | |
download | php-git-7fc04937f5ba48e05d311937477ba81b0e07ffa8.tar.gz |
Fixed bug #69892
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | Zend/tests/bug69892.phpt | 10 | ||||
-rw-r--r-- | Zend/zend_hash.c | 5 |
3 files changed, 15 insertions, 3 deletions
@@ -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 index 0000000000..d14f85fa52 --- /dev/null +++ b/Zend/tests/bug69892.phpt @@ -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) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index bfff87a67e..9b3fb746af 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -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; |