diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 54c816f3..f58bc27b 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -122,7 +122,7 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts) extFilter += TEXT(")"); // Resize filter buffer - int nbCharAdditional = static_cast(extFilter.length() + lstrlen(exts) + 3); // 3 additional for nulls + int nbCharAdditional = static_cast(extFilter.length() + _tcsclen(exts) + 3); // 3 additional for nulls if (_fileExt) { oldFilter = new TCHAR[_nbCharFileExt]; @@ -146,14 +146,14 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts) // Append new filter TCHAR *pFileExt = _fileExt + _nbCharFileExt; - int curLen = nbCharNewFileExt - _nbCharFileExt; + auto curLen = extFilter.length() + 1; wcscpy_s(pFileExt, curLen, extFilter.c_str()); - _nbCharFileExt += static_cast(extFilter.length()) + 1; + _nbCharFileExt += static_cast(curLen); pFileExt = _fileExt + _nbCharFileExt; - curLen = nbCharNewFileExt - _nbCharFileExt; + curLen = _tcsclen(exts) + 1; wcscpy_s(pFileExt, curLen, exts); - _nbCharFileExt += lstrlen(exts) + 1; + _nbCharFileExt += static_cast(curLen); // Set file dialog pointer _ofn.lpstrFilter = _fileExt;