diff options
author | Ivan Sorokin <unxed@mail.ru> | 2022-02-02 13:41:27 +0300 |
---|---|---|
committer | Ivan Sorokin <unxed@mail.ru> | 2022-02-02 13:41:27 +0300 |
commit | ea3695e3136bae147e0bcf5aa51cf17d1a97a490 (patch) | |
tree | 4d40af3b6cceafe0036aa308a10716e5dd5f2f10 /far2l/src/filestr.cpp | |
parent | 7ca3e1c66f227182e144ea1fff8654ddb3cc2a59 (diff) |
far2l code only checked for errors when transcoding a string if the output string had zero length. This is incorrect: during transcoding, not the entire string, but only part of it could be lost, and such cases were not treated as transcoding errors. This commit fixes that.
Diffstat (limited to 'far2l/src/filestr.cpp')
-rw-r--r-- | far2l/src/filestr.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/far2l/src/filestr.cpp b/far2l/src/filestr.cpp index d96620e6..0ff255ee 100644 --- a/far2l/src/filestr.cpp +++ b/far2l/src/filestr.cpp @@ -104,13 +104,13 @@ int OldGetFileString::GetString(wchar_t **DestStr, int nCodePage, int &Length) (SomeDataLost || nCodePage==CP_UTF7) ? 0 : MB_ERR_INVALID_CHARS, Str, Length, wStr, m_nwStrLength - 1); - if (!nResultLength) - { - ret = WINPORT(GetLastError)(); + ret = WINPORT(GetLastError)(); - if (ERROR_NO_UNICODE_TRANSLATION == ret) + if (ERROR_NO_UNICODE_TRANSLATION == ret) + { + SomeDataLost = true; + if (!nResultLength) { - SomeDataLost = true; bGet = true; } } @@ -789,12 +789,12 @@ int GetFileString::GetString(LPWSTR* DestStr, UINT nCodePage, int& Length) (context.SomeDataLost || nCodePage==CP_UTF7) ? 0 : MB_ERR_INVALID_CHARS, Str, Length, &Buffer[0], Buffer.size()-1); - if (!nResultLength) + Result = WINPORT(GetLastError)(); + if (Result == ERROR_NO_UNICODE_TRANSLATION) { - Result = WINPORT(GetLastError)(); - if (Result == ERROR_NO_UNICODE_TRANSLATION) + context.SomeDataLost = true; + if (!nResultLength) { - context.SomeDataLost = true; bGet = true; } } |