Skip to content

Commit 70732b0

Browse files
authored
[TASKMGR] Work around memory leak in performance tab of taskmgr (reactos#8017)
* [TASKMGR] Work around Taskmgr memory leak by changing heap allocation methodology. CORE-18014
1 parent 3c35117 commit 70732b0

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

base/applications/taskmgr/perfdata.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ BOOL PerfDataInitialize(void)
6464
* Create the SYSTEM Sid
6565
*/
6666
AllocateAndInitializeSid(&NtSidAuthority, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &SystemUserSid);
67-
return TRUE;
67+
68+
/*
69+
* Set up global info storage
70+
*/
71+
SystemProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)HeapAlloc(GetProcessHeap(),
72+
0, sizeof(*SystemProcessorTimeInfo) * SystemBasicInfo.NumberOfProcessors);
73+
74+
return SystemProcessorTimeInfo != NULL;
6875
}
6976

7077
void PerfDataUninitialize(void)
@@ -247,10 +254,12 @@ void PerfDataRefresh(void)
247254
/*
248255
* Save system processor time info
249256
*/
250-
if (SystemProcessorTimeInfo) {
251-
HeapFree(GetProcessHeap(), 0, SystemProcessorTimeInfo);
257+
memcpy(SystemProcessorTimeInfo, SysProcessorTimeInfo,
258+
sizeof(*SystemProcessorTimeInfo) * SystemBasicInfo.NumberOfProcessors);
259+
260+
if (SysProcessorTimeInfo) {
261+
HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
252262
}
253-
SystemProcessorTimeInfo = SysProcessorTimeInfo;
254263

255264
/*
256265
* Save system handle info

0 commit comments

Comments
 (0)