Author: cwittich
Date: Sun Oct 7 04:21:58 2007
New Revision: 29431
URL:
http://svn.reactos.org/svn/reactos?rev=29431&view=rev
Log:
-fix a resource leak and two memory leaks
Modified:
trunk/reactos/base/applications/mscutils/servman/listview.c
trunk/reactos/base/applications/mscutils/servman/mainwnd.c
trunk/reactos/base/applications/mscutils/servman/propsheet.c
trunk/reactos/base/applications/mscutils/servman/query.c
Modified: trunk/reactos/base/applications/mscutils/servman/listview.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/listview.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/listview.c Sun Oct 7 04:21:58 2007
@@ -42,10 +42,10 @@
EnableMenuItem(hMainMenu,
ID_PROP,
MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu,
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0),
ID_PROP,
MF_ENABLED);
- SetMenuDefaultItem(Info->hShortcutMenu,
+ SetMenuDefaultItem(GetSubMenu(Info->hShortcutMenu, 0),
ID_PROP,
MF_BYCOMMAND);
}
@@ -58,7 +58,7 @@
EnableMenuItem(hMainMenu,
ID_DELETE,
MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu,
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0),
ID_DELETE,
MF_ENABLED);
}
Modified: trunk/reactos/base/applications/mscutils/servman/mainwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/mainwnd.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/mainwnd.c Sun Oct 7 04:21:58 2007
@@ -162,7 +162,7 @@
for (i = ID_START; i <= ID_RESTART; i++)
{
EnableMenuItem(hMainMenu, i, MF_GRAYED);
- EnableMenuItem(Info->hShortcutMenu, ID_START, MF_GRAYED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_START, MF_GRAYED);
SendMessage(Info->hTool, TB_SETSTATE, i,
(LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
}
@@ -175,7 +175,7 @@
SendMessage(Info->hTool, TB_SETSTATE, ID_DELETE,
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
EnableMenuItem(hMainMenu, ID_DELETE, MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu, ID_DELETE, MF_ENABLED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_DELETE,
MF_ENABLED);
}
Flags = Info->pCurrentService->ServiceStatusProcess.dwControlsAccepted;
@@ -184,7 +184,7 @@
if (State == SERVICE_STOPPED)
{
EnableMenuItem(hMainMenu, ID_START, MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu, ID_START, MF_ENABLED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_START, MF_ENABLED);
SendMessage(Info->hTool, TB_SETSTATE, ID_START,
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
}
@@ -192,7 +192,7 @@
if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) )
{
EnableMenuItem(hMainMenu, ID_STOP, MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu, ID_STOP, MF_ENABLED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_STOP, MF_ENABLED);
SendMessage(Info->hTool, TB_SETSTATE, ID_STOP,
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
}
@@ -200,7 +200,7 @@
if ( (Flags & SERVICE_ACCEPT_PAUSE_CONTINUE) && (State ==
SERVICE_RUNNING) )
{
EnableMenuItem(hMainMenu, ID_PAUSE, MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu, ID_PAUSE, MF_ENABLED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_PAUSE, MF_ENABLED);
SendMessage(Info->hTool, TB_SETSTATE, ID_PAUSE,
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
}
@@ -208,7 +208,7 @@
if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) )
{
EnableMenuItem(hMainMenu, ID_RESTART, MF_ENABLED);
- EnableMenuItem(Info->hShortcutMenu, ID_RESTART, MF_ENABLED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_RESTART,
MF_ENABLED);
SendMessage(Info->hTool, TB_SETSTATE, ID_RESTART,
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
}
@@ -218,8 +218,8 @@
/* disable tools which rely on a selected service */
EnableMenuItem(hMainMenu, ID_PROP, MF_GRAYED);
EnableMenuItem(hMainMenu, ID_DELETE, MF_GRAYED);
- EnableMenuItem(Info->hShortcutMenu, ID_PROP, MF_GRAYED);
- EnableMenuItem(Info->hShortcutMenu, ID_DELETE, MF_GRAYED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_PROP, MF_GRAYED);
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_DELETE, MF_GRAYED);
SendMessage(Info->hTool, TB_SETSTATE, ID_PROP,
(LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
SendMessage(Info->hTool, TB_SETSTATE, ID_DELETE,
@@ -347,8 +347,6 @@
/* Create Popup Menu */
Info->hShortcutMenu = LoadMenu(hInstance,
MAKEINTRESOURCE(IDR_POPUP));
- Info->hShortcutMenu = GetSubMenu(Info->hShortcutMenu,
- 0);
Info->bIsUserAnAdmin = IsUserAnAdmin();
if (Info->bIsUserAnAdmin)
@@ -365,7 +363,7 @@
ID_CREATE,
MF_ENABLED);
}
- EnableMenuItem(Info->hShortcutMenu,
+ EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0),
ID_CREATE,
MF_ENABLED);
}
@@ -766,7 +764,7 @@
GetWindowRect(Info->hListView, &lvRect);
if (PtInRect(&lvRect, pt))
{
- TrackPopupMenuEx(Info->hShortcutMenu,
+ TrackPopupMenuEx(GetSubMenu(Info->hShortcutMenu, 0),
TPM_RIGHTBUTTON,
xPos,
yPos,
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/propsheet.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/propsheet.c Sun Oct 7 04:21:58 2007
@@ -180,6 +180,9 @@
WM_SETTEXT,
0,
(LPARAM)pServiceConfig->lpBinaryPathName);
+ HeapFree(ProcessHeap,
+ 0,
+ pServiceConfig);
}
Modified: trunk/reactos/base/applications/mscutils/servman/query.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/query.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/query.c Sun Oct 7 04:21:58 2007
@@ -270,6 +270,13 @@
DWORD ResumeHandle = 0;
*NumServices = 0;
+
+ if (Info->pAllServices != NULL)
+ {
+ HeapFree(ProcessHeap,
+ 0,
+ Info->pAllServices);
+ }
ScHandle = OpenSCManager(NULL,
NULL,