Unverified Commit 6fb40c3b authored by jamesge's avatar jamesge Committed by GitHub

Merge pull request #1056 from yockie/master

fix heap overflow in simple_data_pool
parents 23c66e3b d2c580ec
...@@ -144,7 +144,7 @@ inline void SimpleDataPool::Return(void* data) { ...@@ -144,7 +144,7 @@ inline void SimpleDataPool::Return(void* data) {
} }
std::unique_lock<butil::Mutex> mu(_mutex); std::unique_lock<butil::Mutex> mu(_mutex);
if (_capacity == _size) { if (_capacity == _size) {
const unsigned new_cap = (_capacity == 0 ? 128 : (_capacity * 3 / 2)); const unsigned new_cap = (_capacity <= 1 ? 128 : (_capacity * 3 / 2));
void** new_pool = (void**)malloc(new_cap * sizeof(void*)); void** new_pool = (void**)malloc(new_cap * sizeof(void*));
if (NULL == new_pool) { if (NULL == new_pool) {
mu.unlock(); mu.unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment