From 3f6121278194404f89ea7b22f098e9389e954587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Goddard=20Rosa?= Date: Sun, 28 Mar 2010 21:32:36 -0300 Subject: [PATCH 1/2] bionic: clear only the part of the buffer which is not overwritten afterward MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5ddd93f0557e5a7401460dc9fc8a55b330a79c3a Signed-off-by: André Goddard Rosa --- libc/bionic/malloc_leak.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libc/bionic/malloc_leak.c b/libc/bionic/malloc_leak.c index ad1d2b420..06f99fb66 100644 --- a/libc/bionic/malloc_leak.c +++ b/libc/bionic/malloc_leak.c @@ -211,8 +211,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize, size_t entrySize = (sizeof(size_t) * 2) + (sizeof(intptr_t) * entry->numEntries); if (entrySize < *infoSize) { /* we're writing less than a full entry, clear out the rest */ - /* TODO: only clear out the part we're not overwriting? */ - memset(head, 0, *infoSize); + memset(head + entrySize, 0, *infoSize - entrySize); } else { /* make sure the amount we're copying doesn't exceed the limit */ entrySize = *infoSize; From 350bb359fa5e31e3dfae8be6b1ce7ee3495f0da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Goddard=20Rosa?= Date: Fri, 5 Feb 2010 16:01:05 -0200 Subject: [PATCH 2/2] bionic: fix memory leak in get_malloc_leak_info() error path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Goddard Rosa --- libc/bionic/malloc_leak.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc/bionic/malloc_leak.c b/libc/bionic/malloc_leak.c index 06f99fb66..9796382b2 100644 --- a/libc/bionic/malloc_leak.c +++ b/libc/bionic/malloc_leak.c @@ -198,7 +198,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize, // debug_log("info = %p\n", info); if (*info == NULL) { *overallSize = 0; - goto done; + goto out_nomem_info; } // debug_log("sorting list...\n"); @@ -220,6 +220,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize, head += *infoSize; } +out_nomem_info: dlfree(list); done: