https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2955ed91ab11419e6d405…
commit 2955ed91ab11419e6d4059e9d31dc8708eba46ba
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Dec 23 14:06:03 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Dec 23 14:09:17 2018 +0100
[UMPNPMGR] Use HeapReAlloc() to reallocate the PnP events buffer. Fix a memory leak in
DeviceInstallThread().
---
base/services/umpnpmgr/umpnpmgr.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/base/services/umpnpmgr/umpnpmgr.c b/base/services/umpnpmgr/umpnpmgr.c
index e7e86e760a..94bc37e914 100644
--- a/base/services/umpnpmgr/umpnpmgr.c
+++ b/base/services/umpnpmgr/umpnpmgr.c
@@ -3476,6 +3476,7 @@ DeviceInstallThread(LPVOID lpParameter)
ResetEvent(hNoPendingInstalls);
Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry);
InstallDevice(Params->DeviceIds, showWizard);
+ HeapFree(GetProcessHeap(), 0, Params);
}
}
@@ -3486,10 +3487,11 @@ DeviceInstallThread(LPVOID lpParameter)
static DWORD WINAPI
PnpEventThread(LPVOID lpParameter)
{
- PPLUGPLAY_EVENT_BLOCK PnpEvent;
- ULONG PnpEventSize;
+ DWORD dwRet = ERROR_SUCCESS;
NTSTATUS Status;
RPC_STATUS RpcStatus;
+ PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent;
+ ULONG PnpEventSize;
UNREFERENCED_PARAMETER(lpParameter);
@@ -3509,10 +3511,13 @@ PnpEventThread(LPVOID lpParameter)
if (Status == STATUS_BUFFER_TOO_SMALL)
{
PnpEventSize += 0x400;
- HeapFree(GetProcessHeap(), 0, PnpEvent);
- PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize);
- if (PnpEvent == NULL)
- return ERROR_OUTOFMEMORY;
+ NewPnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize);
+ if (NewPnpEvent == NULL)
+ {
+ dwRet = ERROR_OUTOFMEMORY;
+ break;
+ }
+ PnpEvent = NewPnpEvent;
continue;
}
@@ -3619,7 +3624,7 @@ PnpEventThread(LPVOID lpParameter)
HeapFree(GetProcessHeap(), 0, PnpEvent);
- return ERROR_SUCCESS;
+ return dwRet;
}