Author: khornicek Date: Tue Oct 21 22:58:23 2014 New Revision: 64882 URL: http://svn.reactos.org/svn/reactos?rev=64882&view=rev Log: [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
Modified: trunk/reactos/base/applications/mscutils/servman/export.c trunk/reactos/base/applications/mscutils/servman/mainwnd.c trunk/reactos/base/applications/mscutils/servman/progress.c trunk/reactos/base/applications/mscutils/servman/propsheet_general.c trunk/reactos/base/applications/mscutils/servman/query.c trunk/reactos/base/applications/mscutils/servman/stop_dependencies.c Modified: trunk/reactos/base/applications/mscutils/servman/export.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/servman/export.c?rev=64882&r1=64881&r2=64882&view=diff ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/export.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/export.c [iso-8859-1] Tue Oct 21 22:58:23 2014 @@ -52,7 +52,7 @@ 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 @@ LVText, i, k); - if (LVText != NULL) + if (_tcslen(LVText)) { WriteFile(hFile, LVText, @@ -84,8 +84,8 @@ } } WriteFile(hFile, - &newl, - sizeof(TCHAR), + newl, + sizeof(newl), &dwWritten, NULL); } Modified: trunk/reactos/base/applications/mscutils/servman/mainwnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/servman/mainwnd.c?rev=64882&r1=64881&r2=64882&view=diff ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/mainwnd.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/mainwnd.c [iso-8859-1] Tue Oct 21 22:58:23 2014 @@ -204,9 +204,10 @@ SendMessage(Info->hTool, TB_SETSTATE, ID_RESTART, (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); } - + } + + if(lpServiceConfig) HeapFree(GetProcessHeap(), 0, lpServiceConfig); - } if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) { Modified: trunk/reactos/base/applications/mscutils/servman/progress.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/servman/progress.c?rev=64882&r1=64881&r2=64882&view=diff ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/progress.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/progress.c [iso-8859-1] Tue Oct 21 22:58:23 2014 @@ -167,9 +167,7 @@ 0, (LPARAM)lpProgStr); - HeapFree(GetProcessHeap(), - 0, - lpProgStr); + LocalFree(lpProgStr); } /* Finally, show and update the progress dialog */ Modified: trunk/reactos/base/applications/mscutils/servman/propsheet_general.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/servman/propsheet_general.c?rev=64882&r1=64881&r2=64882&view=diff ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/propsheet_general.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/propsheet_general.c [iso-8859-1] Tue Oct 21 22:58:23 2014 @@ -33,7 +33,6 @@ { hButton = GetDlgItem(hwndDlg, IDC_START); EnableWindow (hButton, TRUE); - HeapFree(GetProcessHeap(), 0, lpServiceConfig); } else if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) { @@ -45,6 +44,9 @@ hButton = GetDlgItem(hwndDlg, IDC_PAUSE); EnableWindow (hButton, TRUE); } + + if(lpServiceConfig) + HeapFree(GetProcessHeap(), 0, lpServiceConfig); hButton = GetDlgItem(hwndDlg, IDC_START_PARAM); EnableWindow(hButton, (State == SERVICE_STOPPED)); Modified: trunk/reactos/base/applications/mscutils/servman/query.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/servman/query.c?rev=64882&r1=64881&r2=64882&view=diff ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/query.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/query.c [iso-8859-1] Tue Oct 21 22:58:23 2014 @@ -270,6 +270,7 @@ HeapFree(ProcessHeap, 0, Info->pAllServices); + Info->pAllServices = NULL; } ScHandle = OpenSCManager(NULL, @@ -319,7 +320,7 @@ if (ScHandle) CloseServiceHandle(ScHandle); - if (!bRet) + if (!bRet && Info->pAllServices) { HeapFree(ProcessHeap, 0, Modified: trunk/reactos/base/applications/mscutils/servman/stop_dependencies.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils/servman/stop_dependencies.c?rev=64882&r1=64881&r2=64882&view=diff ============================================================================== --- trunk/reactos/base/applications/mscutils/servman/stop_dependencies.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/servman/stop_dependencies.c [iso-8859-1] Tue Oct 21 22:58:23 2014 @@ -163,6 +163,8 @@ LB_ADDSTRING, 0, (LPARAM)lpServiceConfig->lpDisplayName); + + HeapFree(GetProcessHeap(), 0, lpServiceConfig); } /* Move onto the next string */