mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
InnoDB bug fix: mem_realloc() didn't preserve the block contents
innobase/include/mem0mem.ic: mem_realloc(): preserve the old buffer contents
This commit is contained in:
parent
d587a36aa1
commit
a09ecb2504
1 changed files with 14 additions and 2 deletions
|
@ -575,9 +575,21 @@ mem_realloc(
|
|||
char* file_name,/* in: file name where called */
|
||||
ulint line) /* in: line where called */
|
||||
{
|
||||
mem_free(buf);
|
||||
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;
|
||||
|
||||
return(mem_alloc_func(n, file_name, line));
|
||||
if (n > size) {
|
||||
void* newbuf = memcpy(mem_alloc_func(n, file_name, line),
|
||||
buf, size);
|
||||
mem_free(buf);
|
||||
buf = newbuf;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
Loading…
Reference in a new issue