diff --git a/compiler-rt/lib/asan/tests/asan_mac_test.h b/compiler-rt/lib/asan/tests/asan_mac_test.h index 4bb563677e5c..3439ccb05bd0 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 bbce4c562687..6ca685685a7b 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 #import +#import 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 3646a278e0ea..80af8b0adf1c 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