1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05: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.
This commit is contained in:
Kalle Olavi Niemitalo 2006-12-31 09:49:13 +02:00 committed by Kalle Olavi Niemitalo
parent 4d10c3fb8c
commit 4ae90c798c

View File

@ -187,7 +187,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;
}