Commit ad1d726c authored by Austin Schuh's avatar Austin Schuh

Handled blocks being too small in arena.cc

When the user passed in a block which was smaller than the Block
structure, this code would blow past the end of the memory and
crash.  Check for that condition.
parent fb0af6d0
...@@ -61,6 +61,9 @@ void Arena::Init() { ...@@ -61,6 +61,9 @@ void Arena::Init() {
cleanup_list_ = 0; cleanup_list_ = 0;
if (options_.initial_block != NULL && options_.initial_block_size > 0) { if (options_.initial_block != NULL && options_.initial_block_size > 0) {
GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block))
<< ": Initial block size too small for header.";
// Add first unowned block to list. // Add first unowned block to list.
Block* first_block = reinterpret_cast<Block*>(options_.initial_block); Block* first_block = reinterpret_cast<Block*>(options_.initial_block);
first_block->size = options_.initial_block_size; first_block->size = options_.initial_block_size;
......
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