Index: lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- lib/sanitizer_common/sanitizer_common_interceptors.inc +++ lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -273,7 +273,7 @@ MetadataHashMap::Handle h(interceptor_metadata_map, (uptr)addr, /* remove */ false, /* create */ false); - if (h.exists()) { + if (addr && h.exists()) { CHECK(!h.created()); CHECK(h->type == CommonInterceptorMetadata::CIMT_FILE); return &h->file; Index: test/asan/TestCases/Darwin/fclose.c =================================================================== --- test/asan/TestCases/Darwin/fclose.c +++ test/asan/TestCases/Darwin/fclose.c @@ -0,0 +1,13 @@ +// RUN: %clang_asan %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s + +#include +#include + +int main(int argc, const char * argv[]) { + fclose(NULL); + fprintf(stderr, "Finished.\n"); + return 0; +} + +// CHECK: Finished.