diff options
Diffstat (limited to 'libc/bionic/malloc_leak.c')
| -rw-r--r-- | libc/bionic/malloc_leak.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libc/bionic/malloc_leak.c b/libc/bionic/malloc_leak.c index 305f954..b21bc6a 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"); @@ -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; @@ -221,6 +220,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize, head += *infoSize; } +out_nomem_info: dlfree(list); done: @@ -323,6 +323,8 @@ static HashEntry* record_backtrace(intptr_t* backtrace, size_t numEntries, size_ } else { // create a new entry entry = (HashEntry*)dlmalloc(sizeof(HashEntry) + numEntries*sizeof(intptr_t)); + if (!entry) + return NULL; entry->allocations = 1; entry->slot = slot; entry->prev = NULL; @@ -665,8 +667,9 @@ void* chk_realloc(void* mem, size_t bytes) } if (new_buffer) { - size_t size = (bytes < old_bytes)?(bytes):(old_bytes); - memcpy(new_buffer, mem, size); + if (bytes > old_bytes) + bytes = old_bytes; + memcpy(new_buffer, mem, bytes); chk_free(mem); } |
