diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index d1c793c551f7..9da1822f32db 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -304,7 +304,7 @@ INTERCEPTOR(SIZE_T, strnlen, const char *s, SIZE_T maxlen) { INTERCEPTOR(char*, textdomain, const char *domainname) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, textdomain, domainname); - COMMON_INTERCEPTOR_READ_STRING(ctx, domainname, 0); + if (domainname) COMMON_INTERCEPTOR_READ_STRING(ctx, domainname, 0); char *domain = REAL(textdomain)(domainname); if (domain) { COMMON_INTERCEPTOR_INITIALIZE_RANGE(domain, REAL(strlen)(domain) + 1); diff --git a/compiler-rt/test/asan/TestCases/textdomain.c b/compiler-rt/test/asan/TestCases/textdomain.c new file mode 100644 index 000000000000..31e5139c9f7c --- /dev/null +++ b/compiler-rt/test/asan/TestCases/textdomain.c @@ -0,0 +1,10 @@ +// RUN: %clang_asan -O0 -g %s -o %t +// RUN: %env_asan_opts=strict_string_checks=1 %run %t + +#include +#include + +int main() { + textdomain(NULL); + return 0; +}