forked from OSchip/llvm-project
[msan] Fix fcvt interceptor.
fcvt() result can be heap-allocated and must be unpoisoned. llvm-svn: 215106
This commit is contained in:
parent
a3d4dc9eb4
commit
37e069c2ac
|
@ -577,6 +577,7 @@ INTERCEPTOR(char *, fcvt, double x, int a, int *b, int *c) {
|
|||
if (!__msan_has_dynamic_component()) {
|
||||
__msan_unpoison(b, sizeof(*b));
|
||||
__msan_unpoison(c, sizeof(*c));
|
||||
if (res) __msan_unpoison(res, REAL(strlen)(res) + 1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -2064,8 +2064,26 @@ TEST(MemorySanitizer, fcvt) {
|
|||
char *str = fcvt(12345.6789, 10, &a, &b);
|
||||
EXPECT_NOT_POISONED(a);
|
||||
EXPECT_NOT_POISONED(b);
|
||||
ASSERT_NE(nullptr, str);
|
||||
EXPECT_NOT_POISONED(str[0]);
|
||||
ASSERT_NE(0U, strlen(str));
|
||||
}
|
||||
|
||||
TEST(MemorySanitizer, fcvt_long) {
|
||||
int a, b;
|
||||
break_optimization(&a);
|
||||
break_optimization(&b);
|
||||
EXPECT_POISONED(a);
|
||||
EXPECT_POISONED(b);
|
||||
char *str = fcvt(111111112345.6789, 10, &a, &b);
|
||||
EXPECT_NOT_POISONED(a);
|
||||
EXPECT_NOT_POISONED(b);
|
||||
ASSERT_NE(nullptr, str);
|
||||
EXPECT_NOT_POISONED(str[0]);
|
||||
ASSERT_NE(0U, strlen(str));
|
||||
}
|
||||
|
||||
|
||||
TEST(MemorySanitizer, memchr) {
|
||||
char x[10];
|
||||
break_optimization(x);
|
||||
|
|
Loading…
Reference in New Issue