Skip to content

Commit ec023e4

Browse files
committed
Check array flags
1 parent b3a10d8 commit ec023e4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Zend/zend_execute.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5342,8 +5342,7 @@ static bool zend_verify_type_inference(uint32_t type_mask, zval *value)
53425342
value = Z_REFVAL_P(value);
53435343
}
53445344

5345-
uint32_t type = 1u << Z_TYPE_P(value);
5346-
if (!(type_mask & type)) {
5345+
if (!(type_mask & (1u << Z_TYPE_P(value)))) {
53475346
return false;
53485347
}
53495348

@@ -5352,6 +5351,19 @@ static bool zend_verify_type_inference(uint32_t type_mask, zval *value)
53525351
uint32_t num_checked = 0;
53535352
zend_string *str;
53545353
zval *val;
5354+
if (HT_IS_INITIALIZED(ht)) {
5355+
if (zend_hash_num_elements(ht) == 0
5356+
&& !(type_mask & MAY_BE_ARRAY_EMPTY)
5357+
&& (MAY_BE_PACKED(type_mask) || MAY_BE_PACKED(type_mask))) {
5358+
return false;
5359+
}
5360+
if (HT_IS_PACKED(ht) && !MAY_BE_PACKED(type_mask)) {
5361+
return false;
5362+
}
5363+
if (!HT_IS_PACKED(ht) && !MAY_BE_HASH(type_mask)) {
5364+
return false;
5365+
}
5366+
}
53555367
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, str, val) {
53565368
if (str) {
53575369
if (!(type_mask & MAY_BE_ARRAY_KEY_STRING)) {

0 commit comments

Comments
 (0)