From 7aa953c55a9886745cfdef86fcd522b92cb98b9a Mon Sep 17 00:00:00 2001 From: Rajendra Singh Date: Wed, 13 Feb 2019 20:13:54 +0530 Subject: [PATCH] Fix a crash (a regression) due to replacement of lstrcpy by wcscpy_s Close #5314 --- .../src/WinControls/OpenSaveFileDialog/FileDialog.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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;