[compiler-rt] cf6c431 - [HWASAN] Fix memory leaks in tests.
Kirill Stoimenov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 23 15:59:19 PST 2023
Author: Kirill Stoimenov
Date: 2023-01-23T23:59:07Z
New Revision: cf6c43189fd0740c5128d432d18809e819387329
URL: https://github.com/llvm/llvm-project/commit/cf6c43189fd0740c5128d432d18809e819387329
DIFF: https://github.com/llvm/llvm-project/commit/cf6c43189fd0740c5128d432d18809e819387329.diff
LOG: [HWASAN] Fix memory leaks in tests.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D142383
Added:
Modified:
compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c
compiler-rt/test/hwasan/TestCases/print-memory-usage.c
Removed:
################################################################################
diff --git a/compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c b/compiler-rt/test/hwasan/TestCases/Linux/decorate-proc-maps.c
index 5a9208809477f..40e8c0ed8bb75 100644
--- 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 @@ int main(void) {
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
index df9d534f32d4e..534166f572fb8 100644
--- 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 *malloc_and_use(int size) {
}
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) {}
More information about the llvm-commits
mailing list