diff options
Diffstat (limited to 'libc/bionic')
-rw-r--r-- | libc/bionic/malloc_leak.c | 13 | ||||
-rw-r--r-- | libc/bionic/pthread.c | 9 | ||||
-rw-r--r-- | libc/bionic/pututline.c | 2 | ||||
-rw-r--r-- | libc/bionic/ssp.c | 4 |
4 files changed, 15 insertions, 13 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); } diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c index 8171aac..7d4056d 100644 --- a/libc/bionic/pthread.c +++ b/libc/bionic/pthread.c @@ -597,13 +597,12 @@ int pthread_join(pthread_t thid, void ** ret_val) for (thread = gThreadList; thread != NULL; thread = thread->next) if (thread == (pthread_internal_t*)thid) - break; + goto FoundIt; - if (!thread) { - pthread_mutex_unlock(&gThreadListLock); - return ESRCH; - } + pthread_mutex_unlock(&gThreadListLock); + return ESRCH; +FoundIt: if (thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) { pthread_mutex_unlock(&gThreadListLock); return EINVAL; diff --git a/libc/bionic/pututline.c b/libc/bionic/pututline.c index 2449068..c8427f7 100644 --- a/libc/bionic/pututline.c +++ b/libc/bionic/pututline.c @@ -34,7 +34,7 @@ void pututline(struct utmp* utmp) { FILE* f; struct utmp u; - int i; + long i; if (!(f = fopen(_PATH_UTMP, "w+"))) return; diff --git a/libc/bionic/ssp.c b/libc/bionic/ssp.c index 20794f4..f83b2a4 100644 --- a/libc/bionic/ssp.c +++ b/libc/bionic/ssp.c @@ -76,9 +76,9 @@ void __stack_chk_fail(void) sigprocmask(SIG_BLOCK, &sigmask, NULL); /* Use /proc/self/exe link to obtain the program name for logging - * purposes. If it's not available, we set it to "unknown" */ + * purposes. If it's not available, we set it to "<unknown>" */ if ((count = readlink("/proc/self/exe", path, sizeof(path) - 1)) == -1) { - strlcpy(path, "unknown", sizeof(path)); + strlcpy(path, "<unknown>", sizeof(path)); } else { path[count] = '\0'; } |