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:
parent
4d10c3fb8c
commit
4ae90c798c
@ -187,7 +187,7 @@ mem_mmap_realloc(void *p, size_t old_size, size_t new_size)
|
|||||||
void *p2 = mem_mmap_alloc(new_size);
|
void *p2 = mem_mmap_alloc(new_size);
|
||||||
|
|
||||||
if (p2) {
|
if (p2) {
|
||||||
memcpy(p2, p, old_size);
|
memcpy(p2, p, MIN(old_size, new_size));
|
||||||
mem_mmap_free(p, old_size);
|
mem_mmap_free(p, old_size);
|
||||||
return p2;
|
return p2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user