[PATCH] D40676: [msan] Fix return type of mbrtowc
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 14:16:08 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT319484: [msan] Fix return type of mbrtowc (authored by vitalybuka).
Changed prior to commit:
https://reviews.llvm.org/D40676?vs=125017&id=125018#toc
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D40676
Files:
lib/msan/msan_interceptors.cc
lib/msan/tests/msan_test.cc
Index: lib/msan/tests/msan_test.cc
===================================================================
--- lib/msan/tests/msan_test.cc
+++ lib/msan/tests/msan_test.cc
@@ -2121,13 +2121,15 @@
}
TEST(MemorySanitizer, mbrtowc) {
- const char *x = "abc";
- wchar_t wx;
- mbstate_t mbs;
- memset(&mbs, 0, sizeof(mbs));
- int res = mbrtowc(&wx, x, 3, &mbs);
- EXPECT_GT(res, 0);
- EXPECT_NOT_POISONED(wx);
+ mbstate_t mbs = {};
+
+ wchar_t wc;
+ size_t res = mbrtowc(&wc, "\377", 1, &mbs);
+ EXPECT_EQ(res, -1ULL);
+
+ res = mbrtowc(&wc, "abc", 3, &mbs);
+ EXPECT_GT(res, 0ULL);
+ EXPECT_NOT_POISONED(wc);
}
TEST(MemorySanitizer, wcsftime) {
Index: lib/msan/msan_interceptors.cc
===================================================================
--- lib/msan/msan_interceptors.cc
+++ lib/msan/msan_interceptors.cc
@@ -526,7 +526,8 @@
return res;
}
-INTERCEPTOR(int, mbrtowc, wchar_t *dest, const char *src, SIZE_T n, void *ps) {
+INTERCEPTOR(SIZE_T, mbrtowc, wchar_t *dest, const char *src, SIZE_T n,
+ void *ps) {
ENSURE_MSAN_INITED();
SIZE_T res = REAL(mbrtowc)(dest, src, n, ps);
if (res != (SIZE_T)-1 && dest) __msan_unpoison(dest, sizeof(wchar_t));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40676.125018.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/060aaaea/attachment.bin>
More information about the llvm-commits
mailing list