Fix a crash (a regression) due to replacement of lstrcpy by wcscpy_s

Close #5314
This commit is contained in:
Rajendra Singh 2019-02-13 20:13:54 +05:30 committed by Don HO
parent 501980782f
commit 7aa953c55a

View File

@ -122,7 +122,7 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts)
extFilter += TEXT(")"); extFilter += TEXT(")");
// Resize filter buffer // Resize filter buffer
int nbCharAdditional = static_cast<int32_t>(extFilter.length() + lstrlen(exts) + 3); // 3 additional for nulls int nbCharAdditional = static_cast<int32_t>(extFilter.length() + _tcsclen(exts) + 3); // 3 additional for nulls
if (_fileExt) if (_fileExt)
{ {
oldFilter = new TCHAR[_nbCharFileExt]; oldFilter = new TCHAR[_nbCharFileExt];
@ -146,14 +146,14 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts)
// Append new filter // Append new filter
TCHAR *pFileExt = _fileExt + _nbCharFileExt; TCHAR *pFileExt = _fileExt + _nbCharFileExt;
int curLen = nbCharNewFileExt - _nbCharFileExt; auto curLen = extFilter.length() + 1;
wcscpy_s(pFileExt, curLen, extFilter.c_str()); wcscpy_s(pFileExt, curLen, extFilter.c_str());
_nbCharFileExt += static_cast<int32_t>(extFilter.length()) + 1; _nbCharFileExt += static_cast<int32_t>(curLen);
pFileExt = _fileExt + _nbCharFileExt; pFileExt = _fileExt + _nbCharFileExt;
curLen = nbCharNewFileExt - _nbCharFileExt; curLen = _tcsclen(exts) + 1;
wcscpy_s(pFileExt, curLen, exts); wcscpy_s(pFileExt, curLen, exts);
_nbCharFileExt += lstrlen(exts) + 1; _nbCharFileExt += static_cast<int32_t>(curLen);
// Set file dialog pointer // Set file dialog pointer
_ofn.lpstrFilter = _fileExt; _ofn.lpstrFilter = _fileExt;