Skip to content

Commit

Permalink
Merge pull request #1056 from yockie/master
Browse files Browse the repository at this point in the history
fix heap overflow in simple_data_pool
  • Loading branch information
jamesge committed Mar 8, 2020
2 parents 23c66e3 + d2c580e commit 6fb40c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/brpc/simple_data_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ inline void SimpleDataPool::Return(void* data) {
}
std::unique_lock<butil::Mutex> mu(_mutex);
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*));
if (NULL == new_pool) {
mu.unlock();
Expand Down

0 comments on commit 6fb40c3

Please sign in to comment.