Add a test for NSURL deallocation (issue 70)

llvm-svn: 158843
This commit is contained in:
Alexander Potapenko 2012-06-20 20:28:39 +00:00
parent df7dffb34b
commit 50e788b724
3 changed files with 18 additions and 0 deletions

View File

@ -14,4 +14,5 @@ extern "C" {
void TestGCDSourceCancel();
void TestGCDGroupAsync();
void TestOOBNSObjects();
void TestNSURLDeallocation();
}

View File

@ -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];
}

View File

@ -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