va_end(arg);\r
/* Remainder of the buffer is already zeroed */\r
}\r
- ofn.lpstrFile = new TCHAR[PATH_LENGTH];\r
- if (flags & OFN_NOVALIDATE) {\r
- /* Directory hack. */\r
- _sntprintf_s(ofn.lpstrFile, _countof(ofn.lpstrFile), _TRUNCATE, _T(":%s:"), message_string(NSSM_GUI_BROWSE_FILTER_DIRECTORIES));\r
- ofn.nMaxFile = DIR_LENGTH;\r
- }\r
- else {
- _sntprintf_s(ofn.lpstrFile, _countof(ofn.lpstrFile), _TRUNCATE, _T("%s"), current);\r
- ofn.nMaxFile = PATH_LENGTH;\r
+ ofn.lpstrFile = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, PATH_LENGTH * sizeof(TCHAR));\r
+ if (ofn.lpstrFile) {
+ if (flags & OFN_NOVALIDATE) {\r
+ /* Directory hack. */\r
+ _sntprintf_s(ofn.lpstrFile, PATH_LENGTH, _TRUNCATE, _T(":%s:"), message_string(NSSM_GUI_BROWSE_FILTER_DIRECTORIES));\r
+ ofn.nMaxFile = DIR_LENGTH;\r
+ }\r
+ else {
+ _sntprintf_s(ofn.lpstrFile, PATH_LENGTH, _TRUNCATE, _T("%s"), current);\r
+ ofn.nMaxFile = PATH_LENGTH;\r
+ }
}
ofn.lpstrTitle = message_string(NSSM_GUI_BROWSE_TITLE);\r
ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | flags;\r
SendMessage(window, WM_SETTEXT, 0, (LPARAM) ofn.lpstrFile);\r
}\r
if (ofn.lpstrFilter) HeapFree(GetProcessHeap(), 0, (void *) ofn.lpstrFilter);\r
-\r
- delete[] ofn.lpstrFile;\r
+ if (ofn.lpstrFile) HeapFree(GetProcessHeap(), 0, ofn.lpstrFile);
}\r
\r
INT_PTR CALLBACK tab_dlg(HWND tab, UINT message, WPARAM w, LPARAM l) {\r