1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Bug 919, mem_mmap_realloc: Don't overflow the buffer when shrinking it.

The bug was possible only #ifndef HAVE_MREMAP, thus not on Linux.

Backported from ELinks 0.12.GIT (4ae90c798c).
This commit is contained in:
Kalle Olavi Niemitalo 2006-12-31 09:49:13 +02:00 committed by Kalle Olavi Niemitalo
parent d18333075d
commit 1f65dd2802

View File

@ -175,7 +175,7 @@ mem_mmap_realloc(void *p, size_t old_size, size_t new_size)
void *p2 = mem_mmap_alloc(new_size);
if (p2) {
memcpy(p2, p, old_size);
memcpy(p2, p, MIN(old_size, new_size));
mem_mmap_free(p, old_size);
return p2;
}