diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2019-10-28 13:41:45 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2019-10-28 13:41:45 +0100 |
commit | f3b51eb9352d7a7c5dfa15615efc8bc0a52ffecf (patch) | |
tree | b580be6a30428150b6ec40ca5da5bb96ee746fb1 /src/fs.cpp | |
parent | a25945318fdc2890a141a28843c2c5af251c9605 (diff) |
Fix occurences of c_str() used with size() to data()
Using `data()` better communicates the intent here.
Also, depending on how `c_str()` is implemented, this fixes undefined
behavior: The part of the string after the first NULL character might
have undefined contents.
Diffstat (limited to 'src/fs.cpp')
-rw-r--r-- | src/fs.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/fs.cpp b/src/fs.cpp index 7b422b8d70..73fb3b606e 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -107,10 +107,10 @@ std::string get_filesystem_error_message(const fs::filesystem_error& e) #else // Convert from Multi Byte to utf-16 std::string mb_string(e.what()); - int size = MultiByteToWideChar(CP_ACP, 0, mb_string.c_str(), mb_string.size(), nullptr, 0); + int size = MultiByteToWideChar(CP_ACP, 0, mb_string.data(), mb_string.size(), nullptr, 0); std::wstring utf16_string(size, L'\0'); - MultiByteToWideChar(CP_ACP, 0, mb_string.c_str(), mb_string.size(), &*utf16_string.begin(), size); + MultiByteToWideChar(CP_ACP, 0, mb_string.data(), mb_string.size(), &*utf16_string.begin(), size); // Convert from utf-16 to utf-8 return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>().to_bytes(utf16_string); #endif |