Commit 706c5592 authored by marko's avatar marko

branches/zip: mem_heap_block_free(): Fix a bug introduced in r914

while trying to fix r909: invoke mem_erase_buf() before freeing the
buffer, but after interpreting block->buf_block.
parent d6c68479
...@@ -489,9 +489,10 @@ mem_heap_block_free( ...@@ -489,9 +489,10 @@ mem_heap_block_free(
mem_heap_t* heap, /* in: heap */ mem_heap_t* heap, /* in: heap */
mem_block_t* block) /* in: block to free */ mem_block_t* block) /* in: block to free */
{ {
ulint type; ulint type;
ulint len; ulint len;
ibool init_block; ibool init_block;
buf_block_t* buf_block;
if (block->magic_n != MEM_BLOCK_MAGIC_N) { if (block->magic_n != MEM_BLOCK_MAGIC_N) {
mem_analyze_corruption(block); mem_analyze_corruption(block);
...@@ -509,32 +510,33 @@ mem_heap_block_free( ...@@ -509,32 +510,33 @@ mem_heap_block_free(
type = heap->type; type = heap->type;
len = block->len; len = block->len;
init_block = block->init_block; init_block = block->init_block;
buf_block = block->buf_block;
block->magic_n = MEM_FREED_BLOCK_MAGIC_N; block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
#ifdef UNIV_MEM_DEBUG
/* In the debug version we set the memory to a random combination
of hex 0xDE and 0xAD. */
mem_erase_buf((byte*)block, len);
#endif
if (init_block) { if (init_block) {
/* Do not have to free: do nothing */ /* Do not have to free: do nothing */
} else if (type == MEM_HEAP_DYNAMIC) { } else if (type == MEM_HEAP_DYNAMIC) {
ut_ad(!block->buf_block); ut_ad(!buf_block);
mem_area_free(block, mem_comm_pool); mem_area_free(block, mem_comm_pool);
} else { } else {
ut_ad(type & MEM_HEAP_BUFFER); ut_ad(type & MEM_HEAP_BUFFER);
if (len >= UNIV_PAGE_SIZE / 2) { if (len >= UNIV_PAGE_SIZE / 2) {
buf_block_free(block->buf_block); buf_block_free(buf_block);
} else { } else {
ut_ad(!block->buf_block); ut_ad(!buf_block);
mem_area_free(block, mem_comm_pool); mem_area_free(block, mem_comm_pool);
} }
} }
#ifdef UNIV_MEM_DEBUG
/* In the debug version we set the memory to a random combination
of hex 0xDE and 0xAD. */
mem_erase_buf((byte*)block, len);
#endif
} }
/********************************************************************** /**********************************************************************
......
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