Fix: Dangling pointer when assigning _TR/_L result to LPCTSTR

_TR() and _L() return temporary CString objects. Assigning them
directly to raw pointer fields (m_ofn.lpstrTitle) causes use-after-free.
Use local CString variable to extend lifetime.
This commit is contained in:
yuanyuanxiang
2026-01-30 16:32:12 +01:00
parent 91ddf936dc
commit 57f1a5075f
2 changed files with 4 additions and 2 deletions

View File

@@ -1643,7 +1643,8 @@ void CMachineDlg::ShowHostsList_menu()
LPBYTE lpBuffer = NULL;
CFileDialog dlg(TRUE, _T("*.txt"), NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY,
_T("图片文件(*.txt;*.txt)|*.txt;*.txt| All Files (*.*) |*.*||"), NULL);
dlg.m_ofn.lpstrTitle = _L(_T("选择文件"));
CString strTitle = _L(_T("选择文件"));
dlg.m_ofn.lpstrTitle = strTitle;
if (dlg.DoModal() != IDOK)
break;