Skip to content

Commit

Permalink
UnicodeString.cpp: Fix crash when generating HTML report.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Oct 3, 2017
1 parent 3f0ab7f commit ef9c6dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Src/Common/UnicodeString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ String format_arg_list(const TCHAR *fmt, va_list args)
std::vector<TCHAR> buffer(length, 0);
while (result == -1)
{
result = _vsntprintf_s(&buffer[0], length, length, fmt, args);
result = _vsntprintf_s(&buffer[0], length, _TRUNCATE, fmt, args);
length *= 2;
buffer.resize(length, 0);
}
Expand Down
7 changes: 7 additions & 0 deletions Testing/GoogleTest/UnicodeString/UnicodeString_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,11 @@ namespace
EXPECT_NE(0, strutils::compare_nocase(_T("abc"), _T("aDc")));
}

TEST_F(UnicodeStringTest, Format1)
{
EXPECT_TRUE(String(255, ' ') == strutils::format(_T("%s"), String(255, ' ').c_str()));
EXPECT_TRUE(String(256, ' ') == strutils::format(_T("%s"), String(256, ' ').c_str()));
EXPECT_TRUE(String(257, ' ') == strutils::format(_T("%s"), String(257, ' ').c_str()));
}

} // namespace

0 comments on commit ef9c6dc

Please sign in to comment.