From 4ae90c798c7bdd46f9f306169df6064c469783c3 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 31 Dec 2006 09:49:13 +0200 Subject: [PATCH] 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. --- src/util/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/memory.c b/src/util/memory.c index 81dfbc82a..78ef23d23 100644 --- a/src/util/memory.c +++ b/src/util/memory.c @@ -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; }