Commit abbecc61 authored by unknown's avatar unknown

InnoDB bug fix: mem_realloc() didn't preserve the block contents


innobase/include/mem0mem.ic:
  mem_realloc(): preserve the old buffer contents
parent 9ed3c760
......@@ -575,9 +575,21 @@ mem_realloc(
char* file_name,/* in: file name where called */
ulint line) /* in: line where called */
{
mem_heap_t* heap = (mem_heap_t*)((byte*)buf
- MEM_BLOCK_HEADER_SIZE - MEM_FIELD_HEADER_SIZE);
ulint size;
ut_a(heap->magic_n == MEM_BLOCK_MAGIC_N);
size = mem_block_get_len(heap);
ut_a(size > MEM_BLOCK_HEADER_SIZE + MEM_FIELD_HEADER_SIZE);
size -= MEM_BLOCK_HEADER_SIZE + MEM_FIELD_HEADER_SIZE;
if (n > size) {
void* newbuf = memcpy(mem_alloc_func(n, file_name, line),
buf, size);
mem_free(buf);
return(mem_alloc_func(n, file_name, line));
buf = newbuf;
}
return(buf);
}
/**************************************************************************
......
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