This commit is contained in:
Nikita Popov 2015-06-20 17:23:58 +02:00
parent 5bf7a3aac7
commit e8217a2727
4 changed files with 23 additions and 3 deletions

1
NEWS
View File

@ -24,6 +24,7 @@ PHP NEWS
(Christian Wenz)
. Fixed bug #69889 (Null coalesce operator doesn't work for string offsets).
(Nikita)
. Fixed bug #69891 (Unexpected array comparison result). (Nikita)
. Fixed bug #69892 (Different arrays compare indentical due to integer key
truncation). (Nikita)
. Fixed bug #69893 (Strict comparison between integer and empty string keys

12
Zend/tests/bug69891.phpt Normal file
View File

@ -0,0 +1,12 @@
--TEST--
Bug #69891: Unexpected array comparison result
--FILE--
<?php
var_dump([1, 2, 3] <=> []);
var_dump([] <=> [1, 2, 3]);
var_dump([1] <=> [2, 3]);
--EXPECT--
int(1)
int(-1)
int(-1)

8
Zend/tests/bug69893.phpt Normal file
View File

@ -0,0 +1,8 @@
--TEST--
Bug #69893: Strict comparison between integer and empty string keys crashes
--FILE--
<?php
var_dump([0 => 0] === ["" => 0]);
?>
--EXPECT--
bool(false)

View File

@ -2220,11 +2220,10 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
HASH_PROTECT_RECURSION(ht1);
HASH_PROTECT_RECURSION(ht2);
result = ht1->nNumOfElements - ht2->nNumOfElements;
if (result!=0) {
if (ht1->nNumOfElements != ht2->nNumOfElements) {
HASH_UNPROTECT_RECURSION(ht1);
HASH_UNPROTECT_RECURSION(ht2);
return result;
return ht1->nNumOfElements > ht2->nNumOfElements ? 1 : -1;
}
for (idx1 = 0, idx2 = 0; idx1 < ht1->nNumUsed; idx1++) {