1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 11:13:36 +02:00

Assert that HT entries using add_new APIs are really new

This commit is contained in:
Nikita Popov
2019-07-04 15:08:47 +02:00
parent ef05eab432
commit 6a9127c100
+4 -2
View File
@@ -725,12 +725,13 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s
zend_string_hash_val(key);
}
}
} else if ((flag & HASH_ADD_NEW) == 0) {
} else if ((flag & HASH_ADD_NEW) == 0 || ZEND_DEBUG) {
p = zend_hash_find_bucket(ht, key, 0);
if (p) {
zval *data;
ZEND_ASSERT((flag & HASH_ADD_NEW) == 0);
if (flag & HASH_ADD) {
if (!(flag & HASH_UPDATE_INDIRECT)) {
return NULL;
@@ -1012,9 +1013,10 @@ convert_to_hash:
}
zend_hash_real_init_mixed(ht);
} else {
if ((flag & HASH_ADD_NEW) == 0) {
if ((flag & HASH_ADD_NEW) == 0 || ZEND_DEBUG) {
p = zend_hash_index_find_bucket(ht, h);
if (p) {
ZEND_ASSERT((flag & HASH_ADD_NEW) == 0);
goto replace;
}
}