diff --git a/compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c b/compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c --- a/compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c +++ b/compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c @@ -51,5 +51,8 @@ void * volatile res2 = malloc(100000); pthread_create(&t, 0, ThreadFn, 0); pthread_join(t, 0); - return (int)(size_t)res; + int ret_val = (int)(size_t)res; + free(res); + free(res2); + return ret_val; } diff --git a/compiler-rt/test/hwasan/TestCases/print-memory-usage.c b/compiler-rt/test/hwasan/TestCases/print-memory-usage.c --- a/compiler-rt/test/hwasan/TestCases/print-memory-usage.c +++ b/compiler-rt/test/hwasan/TestCases/print-memory-usage.c @@ -23,9 +23,10 @@ } void *T1(void *arg) { - - for (int i = 1; i <= (1 << 20); i *= 2) + for (int i = 1; i <= (1 << 20); i *= 2) { sink = malloc_and_use(i); + free(sink); + } __sync_fetch_and_add(&state, 1); while (__sync_fetch_and_add(&state, 0) != 4) {}