diff options
-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 |