Skip to content

Commit e6f30cb

Browse files
committed
ErrorStringFromLastError() fixed to not include CR/LF
1 parent 9088c7e commit e6f30cb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

system/win_utils.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ std::string ErrorStringFromErrorCode(const DWORD errCode) noexcept
1919

2020
assert_and_return_message_r(nCharsWritten > 0, "FormatMessageA failed with error code " + std::to_string(::GetLastError()), {});
2121

22-
return std::string(msgBuf, nCharsWritten);
22+
std::string str(msgBuf, nCharsWritten);
23+
if (str.ends_with("\r\n"))
24+
str[str.size() - 2] = '\0'; // Remove trailing CRLF
25+
26+
return str;
2327
}
2428

2529
std::string ErrorStringFromLastError() noexcept

0 commit comments

Comments
 (0)