Commit b292dfea authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 5

Don't use a VLA for the dest buffer when testing wide FBString to multi-byte FBString

Summary: Because MSVC doesn't support VLA's.

Reviewed By: yfeldblum

Differential Revision: D3507441

fbshipit-source-id: a50bdbad31674d236e4994903c75232d70f32bc0
parent 35e9dfc7
......@@ -53,9 +53,10 @@ enum { BUF_SIZE = 4096 };
ssize_t writeToFD(int fd, size_t length) {
// write an arbitrary amount of data to the fd
char buf[length];
memset(buf, 'a', sizeof(buf));
ssize_t rc = write(fd, buf, sizeof(buf));
auto bufv = vector<char>(length);
auto buf = bufv.data();
memset(buf, 'a', length);
ssize_t rc = write(fd, buf, length);
CHECK_EQ(rc, length);
return rc;
}
......@@ -79,8 +80,8 @@ size_t writeUntilFull(int fd) {
ssize_t readFromFD(int fd, size_t length) {
// write an arbitrary amount of data to the fd
char buf[length];
return read(fd, buf, sizeof(buf));
auto buf = vector<char>(length);
return read(fd, buf.data(), length);
}
size_t readUntilEmpty(int fd) {
......
......@@ -1018,8 +1018,9 @@ TEST(FBString, testAllClauses) {
rng = RandomT(localSeed);
f_wfbstring(wc);
int wret = wcslen(wc.c_str());
char mb[wret+1];
int ret = wcstombs(mb, wc.c_str(), sizeof(mb));
auto mbv = std::vector<char>(wret + 1);
auto mb = mbv.data();
int ret = wcstombs(mb, wc.c_str(), wret + 1);
if (ret == wret) mb[wret] = '\0';
const char *mc = c.c_str();
std::string one(mb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment