Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h @@ -769,6 +769,9 @@ } bool PointerIsMine(const void *p) { + uptr mem = reinterpret_cast(p); + if (mem < kSpaceBeg || mem >= kSpaceBeg + kSpaceSize) + return false; return GetSizeClass(p) != 0; } Index: compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_size_crash.mm =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_size_crash.mm +++ compiler-rt/trunk/test/asan/TestCases/Darwin/malloc_size_crash.mm @@ -0,0 +1,15 @@ +// RUN: %clang_asan %s -o %t -framework Foundation +// RUN: %run %t 2>&1 | FileCheck %s + +#import +#include + +int main(int argc, char *argv[]) { + id obj = @0; + fprintf(stderr, "obj = %p\n", obj); + size_t size = malloc_size(obj); + fprintf(stderr, "size = 0x%zx\n", size); + fprintf(stderr, "Done.\n"); + // CHECK: Done. + return 0; +}