summaryrefslogtreecommitdiffstats
path: root/libc/bionic/malloc_debug_common.c
diff options
context:
space:
mode:
authortedbo <tedbo@google.com>2010-10-05 13:06:06 -0700
committertedbo <tedbo@google.com>2010-10-05 13:23:28 -0700
commit9d8be5485c366b4f579bef0b88a4c99b899f21e1 (patch)
tree9ffa7d64f6896681d17944af40ed29d3050827fd /libc/bionic/malloc_debug_common.c
parentabdb3695b21631ace52123fbe68f86fa4476a4b0 (diff)
downloadbionic-9d8be5485c366b4f579bef0b88a4c99b899f21e1.zip
bionic-9d8be5485c366b4f579bef0b88a4c99b899f21e1.tar.gz
bionic-9d8be5485c366b4f579bef0b88a4c99b899f21e1.tar.bz2
get_malloc_leak_info: Fix assumption that totalMemory out parameter was initialized to zero.
The get_malloc_leak_info() currently asssumes that the totalMemory out parameter was pre-initialized to zero before the routine is called. If it is not then the accumulated totalMemory value will be incorrect. It is likely that many callers will simply allocate totalMemory on the stack with no initialization and assume that get_malloc_leak_info will set the proper value. As an example, the caller in frameworks/base/core/jni/android_os_Debug.cpp calls get_malloc_leak_info() with the address uninitiazed stack variable for totalMemory. It is probably best to fix this in get_malloc_leak_info. Change-Id: I84c927c3781419585794726115b7d34d8fdd24ae
Diffstat (limited to 'libc/bionic/malloc_debug_common.c')
-rw-r--r--libc/bionic/malloc_debug_common.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/bionic/malloc_debug_common.c b/libc/bionic/malloc_debug_common.c
index f05576c..ebf0006 100644
--- a/libc/bionic/malloc_debug_common.c
+++ b/libc/bionic/malloc_debug_common.c
@@ -120,6 +120,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
totalMemory == NULL || backtraceSize == NULL) {
return;
}
+ *totalMemory = 0;
pthread_mutex_lock(&gAllocationsMutex);
@@ -127,7 +128,6 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
*info = NULL;
*overallSize = 0;
*infoSize = 0;
- *totalMemory = 0;
*backtraceSize = 0;
goto done;
}