diff options
author | Alexander Potapenko <glider@google.com> | 2012-06-20 20:28:39 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2012-06-20 20:28:39 +0000 |
commit | 50e788b724c79d8f80c6bd545b14eb1e64e619e0 (patch) | |
tree | 28ec5f33590619d9fd221b3eed7f8b3ec2a82ed4 | |
parent | df7dffb34b459fb05e19e9fa283021665c9f6380 (diff) | |
download | bcm5719-llvm-50e788b724c79d8f80c6bd545b14eb1e64e619e0.tar.gz bcm5719-llvm-50e788b724c79d8f80c6bd545b14eb1e64e619e0.zip |
Add a test for NSURL deallocation (issue 70)
llvm-svn: 158843
-rw-r--r-- | compiler-rt/lib/asan/tests/asan_mac_test.h | 1 | ||||
-rw-r--r-- | compiler-rt/lib/asan/tests/asan_mac_test.mm | 10 | ||||
-rw-r--r-- | compiler-rt/lib/asan/tests/asan_test.cc | 7 |
3 files changed, 18 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/tests/asan_mac_test.h b/compiler-rt/lib/asan/tests/asan_mac_test.h index 4bb563677e5..3439ccb05bd 100644 --- a/compiler-rt/lib/asan/tests/asan_mac_test.h +++ b/compiler-rt/lib/asan/tests/asan_mac_test.h @@ -14,4 +14,5 @@ extern "C" { void TestGCDSourceCancel(); void TestGCDGroupAsync(); void TestOOBNSObjects(); + void TestNSURLDeallocation(); } diff --git a/compiler-rt/lib/asan/tests/asan_mac_test.mm b/compiler-rt/lib/asan/tests/asan_mac_test.mm index bbce4c56268..6ca685685a7 100644 --- a/compiler-rt/lib/asan/tests/asan_mac_test.mm +++ b/compiler-rt/lib/asan/tests/asan_mac_test.mm @@ -7,6 +7,7 @@ #import <CoreFoundation/CFBase.h> #import <Foundation/NSObject.h> +#import <Foundation/NSURL.h> void CFAllocatorDefaultDoubleFree() { void *mem = CFAllocatorAllocate(kCFAllocatorDefault, 5, 0); @@ -223,3 +224,12 @@ void TestOOBNSObjects() { [anObject access:11]; [anObject release]; } + +void TestNSURLDeallocation() { + NSURL *base = + [[NSURL alloc] initWithString:@"file://localhost/Users/glider/Library/"]; + volatile NSURL *u = + [[NSURL alloc] initWithString:@"Saved Application State" + relativeToURL:base]; + [u release]; +} diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc index 3646a278e0e..80af8b0adf1 100644 --- a/compiler-rt/lib/asan/tests/asan_test.cc +++ b/compiler-rt/lib/asan/tests/asan_test.cc @@ -2049,6 +2049,13 @@ TEST(AddressSanitizerMac, NSObjectOOB) { // Make sure that our allocators are used for NSObjects. EXPECT_DEATH(TestOOBNSObjects(), "heap-buffer-overflow"); } + +// Make sure that correct pointer is passed to free() when deallocating a +// NSURL object. +// See http://code.google.com/p/address-sanitizer/issues/detail?id=70. +TEST(AddressSanitizerMac, DISABLED_NSURLDeallocation) { + TestNSURLDeallocation(); +} #endif // __APPLE__ // Test that instrumentation of stack allocations takes into account |