[compiler-rt] r300080 - Fix memory leaks in address sanitizer darwin tests

Francis Ricci via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 10:31:41 PDT 2017


Author: fjricci
Date: Wed Apr 12 12:31:41 2017
New Revision: 300080

URL: http://llvm.org/viewvc/llvm-project?rev=300080&view=rev
Log:
Fix memory leaks in address sanitizer darwin tests

Summary: These leaks are detected by leak sanitizer for darwin.

Reviewers: glider, kubamracek, kcc, alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31978

Modified:
    compiler-rt/trunk/lib/asan/tests/asan_mac_test_helpers.mm
    compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc
    compiler-rt/trunk/test/asan/TestCases/Darwin/scribble.cc
    compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-darwin.cc
    compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-sandbox.cc

Modified: compiler-rt/trunk/lib/asan/tests/asan_mac_test_helpers.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_mac_test_helpers.mm?rev=300080&r1=300079&r2=300080&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_mac_test_helpers.mm (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_mac_test_helpers.mm Wed Apr 12 12:31:41 2017
@@ -237,4 +237,5 @@ void TestNSURLDeallocation() {
       [[NSURL alloc] initWithString:@"Saved Application State"
                      relativeToURL:base];
   [u release];
+  [base release];
 }

Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc?rev=300080&r1=300079&r2=300080&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_set_zone_name-mprotect.cc Wed Apr 12 12:31:41 2017
@@ -47,5 +47,6 @@ int main() {
     memset(mem[i], 'a', 8 * (i % kNumIter));
     free(mem[i]);
   }
+  malloc_destroy_zone(zone);
   return 0;
 }

Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/scribble.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/scribble.cc?rev=300080&r1=300079&r2=300080&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/scribble.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/scribble.cc Wed Apr 12 12:31:41 2017
@@ -54,4 +54,5 @@ int main() {
   fprintf(stderr, "okthxbai!\n");
   // CHECK-SCRIBBLE: okthxbai!
   // CHECK-NOSCRIBBLE: okthxbai!
+  free(my_class_isa);
 }

Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-darwin.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-darwin.cc?rev=300080&r1=300079&r2=300080&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-darwin.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-darwin.cc Wed Apr 12 12:31:41 2017
@@ -27,6 +27,7 @@ int main() {
                               kCFStringEncodingUTF8, FALSE); // BOOM
   fprintf(stderr, "Ignored.\n");
   free(a);
+  CFRelease(str);
 }
 
 // CHECK-CRASH: AddressSanitizer: heap-buffer-overflow

Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-sandbox.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-sandbox.cc?rev=300080&r1=300079&r2=300080&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-sandbox.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/suppressions-sandbox.cc Wed Apr 12 12:31:41 2017
@@ -18,6 +18,7 @@ int main() {
                               kCFStringEncodingUTF8, FALSE);  // BOOM
   fprintf(stderr, "Ignored.\n");
   free(a);
+  CFRelease(str);
 }
 
 // CHECK-CRASH: AddressSanitizer: heap-buffer-overflow




More information about the llvm-commits mailing list