diff --git a/reactos/base/applications/mscutils/servman/export.c b/reactos/base/applications/mscutils/servman/export.c index f637a5d3d59..3df3c4424fb 100644 --- a/reactos/base/applications/mscutils/servman/export.c +++ b/reactos/base/applications/mscutils/servman/export.c @@ -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); } diff --git a/reactos/base/applications/mscutils/servman/mainwnd.c b/reactos/base/applications/mscutils/servman/mainwnd.c index 68233799aab..829148185de 100644 --- a/reactos/base/applications/mscutils/servman/mainwnd.c +++ b/reactos/base/applications/mscutils/servman/mainwnd.c @@ -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); diff --git a/reactos/base/applications/mscutils/servman/progress.c b/reactos/base/applications/mscutils/servman/progress.c index e3c2d6b8949..8c9c843525e 100644 --- a/reactos/base/applications/mscutils/servman/progress.c +++ b/reactos/base/applications/mscutils/servman/progress.c @@ -167,9 +167,7 @@ CreateProgressDialog(HWND hParent, 0, (LPARAM)lpProgStr); - HeapFree(GetProcessHeap(), - 0, - lpProgStr); + LocalFree(lpProgStr); } /* Finally, show and update the progress dialog */ diff --git a/reactos/base/applications/mscutils/servman/propsheet_general.c b/reactos/base/applications/mscutils/servman/propsheet_general.c index 9c33a97171d..6bac4cdfb12 100644 --- a/reactos/base/applications/mscutils/servman/propsheet_general.c +++ b/reactos/base/applications/mscutils/servman/propsheet_general.c @@ -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)); diff --git a/reactos/base/applications/mscutils/servman/query.c b/reactos/base/applications/mscutils/servman/query.c index 14a68e5a938..3a5e82ce612 100644 --- a/reactos/base/applications/mscutils/servman/query.c +++ b/reactos/base/applications/mscutils/servman/query.c @@ -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, diff --git a/reactos/base/applications/mscutils/servman/stop_dependencies.c b/reactos/base/applications/mscutils/servman/stop_dependencies.c index 559002c6073..99b60bbffe9 100644 --- a/reactos/base/applications/mscutils/servman/stop_dependencies.c +++ b/reactos/base/applications/mscutils/servman/stop_dependencies.c @@ -163,6 +163,8 @@ AddServiceNamesToStop(HWND hServiceListBox, LB_ADDSTRING, 0, (LPARAM)lpServiceConfig->lpDisplayName); + + HeapFree(GetProcessHeap(), 0, lpServiceConfig); } /* Move onto the next string */