Skip to content

Commit 5bf7a3a

Browse files
committed
Fixed bug #69893
1 parent 9589d26 commit 5bf7a3a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ PHP NEWS
2626
(Nikita)
2727
. Fixed bug #69892 (Different arrays compare indentical due to integer key
2828
truncation). (Nikita)
29+
. Fixed bug #69893 (Strict comparison between integer and empty string keys
30+
crashes). (Nikita)
2931

3032
- DOM:
3133
. Fixed bug #69846 (Segmenation fault (access violation) when iterating over

Zend/zend_hash.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,20 +2248,24 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
22482248
HASH_UNPROTECT_RECURSION(ht2);
22492249
return p1->h > p2->h ? 1 : -1;
22502250
}
2251-
} else { /* string indices */
2252-
size_t len0 = (p1->key ? p1->key->len : 0);
2253-
size_t len1 = (p2->key ? p2->key->len : 0);
2254-
if (len0 != len1) {
2251+
} else if (p1->key != NULL && p2->key != NULL) { /* string indices */
2252+
if (p1->key->len != p2->key->len) {
22552253
HASH_UNPROTECT_RECURSION(ht1);
22562254
HASH_UNPROTECT_RECURSION(ht2);
2257-
return len0 > len1 ? 1 : -1;
2255+
return p1->key->len > p2->key->len ? 1 : -1;
22582256
}
2257+
22592258
result = memcmp(p1->key->val, p2->key->val, p1->key->len);
22602259
if (result != 0) {
22612260
HASH_UNPROTECT_RECURSION(ht1);
22622261
HASH_UNPROTECT_RECURSION(ht2);
22632262
return result;
22642263
}
2264+
} else {
2265+
/* Mixed key types: A string key is considered as larger */
2266+
HASH_UNPROTECT_RECURSION(ht1);
2267+
HASH_UNPROTECT_RECURSION(ht2);
2268+
return p1->key != NULL ? 1 : -1;
22652269
}
22662270
pData2 = &p2->val;
22672271
} else {

0 commit comments

Comments
 (0)