From eaf96698c7e3229b0217ca3a408fb3b50b9bd333 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 7 Sep 2015 15:02:33 +0200 Subject: [PATCH] Fix bug #70423 Warning Internal error: wrong size calculation --- ext/opcache/zend_persist_calc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index bad7d70cc8..3b8356ae7a 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -60,15 +60,18 @@ static void zend_hash_persist_calc(HashTable *ht, void (*pPersistElement)(zval * if (!(ht->u.flags & HASH_FLAG_PACKED) && ht->nNumUsed < -(int32_t)ht->nTableMask / 2) { /* compact table */ - int32_t hash_size = -(int32_t)ht->nTableMask; + int32_t hash_size; - while (hash_size >> 1 > ht->nNumUsed) { - hash_size >>= 1; - } - if (hash_size < HT_MIN_SIZE) { + if (ht->nNumUsed <= HT_MIN_SIZE) { hash_size = HT_MIN_SIZE; + } else { + hash_size = -(int32_t)ht->nTableMask; + while (hash_size >> 1 > ht->nNumUsed) { + hash_size >>= 1; + } } ADD_SIZE(hash_size * sizeof(uint32_t) + ht->nNumUsed * sizeof(Bucket)); + ZEND_ASSERT(((zend_uintptr_t)ZCG(mem) & 0x7) == 0); /* should be 8 byte aligned */ } else { ADD_SIZE(HT_USED_SIZE(ht)); } -- 2.40.0