File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -202,16 +202,16 @@ class MBmpView : public MWindowBase
202202 // MCI relies on file extension to determine media type; rename .tmp to .avi
203203 // so that compressed AVI files are properly recognized on some systems.
204204 LPTSTR pszDot = _tcsrchr (m_szTempFile, TEXT (' .' ));
205- if (pszDot != NULL )
205+ if (pszDot != NULL && pszDot + 5 <= m_szTempFile + _countof (m_szTempFile) )
206206 {
207- // Ensure buffer has room for ".avi" (4 chars + null terminator)
208- if (pszDot + 5 <= m_szTempFile + _countof (m_szTempFile))
207+ TCHAR szOldPath[MAX_PATH];
208+ _tcscpy_s (szOldPath, m_szTempFile);
209+ _tcscpy_s (pszDot, 5 , TEXT (" .avi" )); // ".avi" + null = 5 chars
210+ // Rename the temp file created by GetTempFileName
211+ if (!MoveFile (szOldPath, m_szTempFile))
209212 {
210- TCHAR szOldPath[MAX_PATH];
211- _tcscpy_s (szOldPath, m_szTempFile);
212- _tcscpy_s (pszDot, _countof (m_szTempFile) - (pszDot - m_szTempFile), TEXT (" .avi" ));
213- // Rename the temp file created by GetTempFileName
214- MoveFile (szOldPath, m_szTempFile);
213+ // Rename failed; revert to original path
214+ _tcscpy_s (m_szTempFile, szOldPath);
215215 }
216216 }
217217
You can’t perform that action at this time.
0 commit comments