Index: lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- lib/sanitizer_common/sanitizer_common_interceptors.inc +++ lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -1724,7 +1724,8 @@ INTERCEPTOR(__sanitizer_passwd *, getpwnam, const char *name) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, getpwnam, name); - COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1); + if (name) + COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1); __sanitizer_passwd *res = REAL(getpwnam)(name); if (res) unpoison_passwd(ctx, res); return res; Index: test/asan/TestCases/Darwin/getpwnam.c =================================================================== --- test/asan/TestCases/Darwin/getpwnam.c +++ test/asan/TestCases/Darwin/getpwnam.c @@ -0,0 +1,15 @@ +// RUN: %clang_asan %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s + +#include +#include +#include +#include + +int main(int argc, const char * argv[]) { + getpwnam(NULL); + fprintf(stderr, "Finished.\n"); + return 0; +} + +// CHECK: Finished.