diff --git a/compiler-rt/lib/msan/tests/msan_test.cpp b/compiler-rt/lib/msan/tests/msan_test.cpp index 7c9af6591787c8..3ddba8c885c922 100644 --- a/compiler-rt/lib/msan/tests/msan_test.cpp +++ b/compiler-rt/lib/msan/tests/msan_test.cpp @@ -3758,6 +3758,7 @@ TEST(MemorySanitizer, wordexp) { ASSERT_STREQ("a", w.we_wordv[0]); ASSERT_STREQ("b", w.we_wordv[1]); ASSERT_STREQ("c", w.we_wordv[2]); + EXPECT_POISONED(w.we_wordv[3]); } TEST(MemorySanitizer, wordexp_initial_offset) { @@ -3770,6 +3771,7 @@ TEST(MemorySanitizer, wordexp_initial_offset) { ASSERT_STREQ("a", w.we_wordv[1]); ASSERT_STREQ("b", w.we_wordv[2]); ASSERT_STREQ("c", w.we_wordv[3]); + EXPECT_POISONED(w.we_wordv[4]); } template diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index e67fca8057aa75..d967c1d936ee78 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -3997,7 +3997,7 @@ INTERCEPTOR(int, wordexp, char *s, __sanitizer_wordexp_t *p, int flags) { if (!res && p) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p, sizeof(*p)); uptr we_wordc = - ((flags & wordexp_wrde_dooffs) ? p->we_wordc : 0) + p->we_wordc; + ((flags & wordexp_wrde_dooffs) ? p->we_offs : 0) + p->we_wordc; if (we_wordc) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p->we_wordv, sizeof(*p->we_wordv) * we_wordc);