[SERVMAN]

- fix resource leaks CID 716292, 716293, 716294
- fix CID 716772 (double free), 513719 (wrong NULL check), 1206739 (cosmetic)
- make line endings CR LF when exporting the services list

svn path=/trunk/; revision=64882
This commit is contained in:
Kamil Hornicek 2014-10-21 22:58:23 +00:00
parent c7f4cb10e3
commit 2ee22c5764
6 changed files with 15 additions and 11 deletions

View file

@ -52,7 +52,7 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
if(hFile != INVALID_HANDLE_VALUE)
{
TCHAR LVText[500];
TCHAR newl = _T('\n');
TCHAR newl[2] = {_T('\r'), _T('\n')};
TCHAR tab = _T('\t');
DWORD dwTextLength, dwWritten;
INT NumListedServ = 0;
@ -68,7 +68,7 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
LVText,
i,
k);
if (LVText != NULL)
if (_tcslen(LVText))
{
WriteFile(hFile,
LVText,
@ -84,8 +84,8 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
}
}
WriteFile(hFile,
&newl,
sizeof(TCHAR),
newl,
sizeof(newl),
&dwWritten,
NULL);
}

View file

@ -204,10 +204,11 @@ VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info)
SendMessage(Info->hTool, TB_SETSTATE, ID_RESTART,
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
}
HeapFree(GetProcessHeap(), 0, lpServiceConfig);
}
if(lpServiceConfig)
HeapFree(GetProcessHeap(), 0, lpServiceConfig);
if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) )
{
EnableMenuItem(hMainMenu, ID_STOP, MF_ENABLED);

View file

@ -167,9 +167,7 @@ CreateProgressDialog(HWND hParent,
0,
(LPARAM)lpProgStr);
HeapFree(GetProcessHeap(),
0,
lpProgStr);
LocalFree(lpProgStr);
}
/* Finally, show and update the progress dialog */

View file

@ -33,7 +33,6 @@ SetButtonStates(PSERVICEPROPSHEET dlgInfo,
{
hButton = GetDlgItem(hwndDlg, IDC_START);
EnableWindow (hButton, TRUE);
HeapFree(GetProcessHeap(), 0, lpServiceConfig);
}
else if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) )
{
@ -46,6 +45,9 @@ SetButtonStates(PSERVICEPROPSHEET dlgInfo,
EnableWindow (hButton, TRUE);
}
if(lpServiceConfig)
HeapFree(GetProcessHeap(), 0, lpServiceConfig);
hButton = GetDlgItem(hwndDlg, IDC_START_PARAM);
EnableWindow(hButton, (State == SERVICE_STOPPED));

View file

@ -270,6 +270,7 @@ GetServiceList(PMAIN_WND_INFO Info,
HeapFree(ProcessHeap,
0,
Info->pAllServices);
Info->pAllServices = NULL;
}
ScHandle = OpenSCManager(NULL,
@ -319,7 +320,7 @@ GetServiceList(PMAIN_WND_INFO Info,
if (ScHandle)
CloseServiceHandle(ScHandle);
if (!bRet)
if (!bRet && Info->pAllServices)
{
HeapFree(ProcessHeap,
0,

View file

@ -163,6 +163,8 @@ AddServiceNamesToStop(HWND hServiceListBox,
LB_ADDSTRING,
0,
(LPARAM)lpServiceConfig->lpDisplayName);
HeapFree(GetProcessHeap(), 0, lpServiceConfig);
}
/* Move onto the next string */