com php-src: We should not silently go on if the required size can not be met: Zend/zend_hash.c

From: Date: Wed, 12 Aug 2015 08:44:51 +0000
Subject: com php-src: We should not silently go on if the required size can not be met: Zend/zend_hash.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-88489@lists.php.net to get a copy of this message
Commit: d75228e201e382dbf328e5141a7c9ca279d09a45 Author: Xinchen Hui <laruence@php.net> Wed, 12 Aug 2015 16:44:51 +0800 Parents: 60b75eb9ed77cb9f8080a07f3d8228ac66176cec Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d75228e201e382dbf328e5141a7c9ca279d09a45 Log: We should not silently go on if the required size can not be met Changed paths: M Zend/zend_hash.c Diff: diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 96ed679...d010dff 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -97,7 +97,11 @@ static uint32_t zend_always_inline zend_hash_check_size(uint32_t nSize) /* Use big enough power of 2 */ /* size should be between HT_MIN_SIZE and HT_MAX_SIZE */ - nSize = (nSize <= HT_MIN_SIZE ? HT_MIN_SIZE : (nSize >= HT_MAX_SIZE ? HT_MAX_SIZE : nSize)); + if (nSize < HT_MIN_SIZE) { + nSize = HT_MIN_SIZE; + } else if (UNEXPECTED(nSize >= HT_MAX_SIZE)) { + zend_error_noreturn(E_ERROR, "Array size is too big", nSize); + } #if defined(ZEND_WIN32) if (BitScanReverse(&index, nSize - 1)) {

« previous php.cvs (#88489) next »