Skip to content

Commit 01c7f3c

Browse files
Copilotguhetiercsujedihy
authored
Fix memory leak in PerfServer DelayWorker initialization failure (#5213)
* Fix memory leak in DelayWorker initialization failure Co-authored-by: guhetier <[email protected]> * Fix DelayWorker cleanup loop to only shutdown initialized workers Co-authored-by: csujedihy <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: guhetier <[email protected]> Co-authored-by: csujedihy <[email protected]>
1 parent 27a54a1 commit 01c7f3c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/perf/lib/PerfServer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,17 @@ PerfServer::Init(
106106

107107
ProcCount = (uint16_t)CxPlatProcCount();
108108
DelayWorkers = new (std::nothrow) DelayWorker[ProcCount];
109+
if (!DelayWorkers) {
110+
WriteOutput("Failed to allocate delay workers.\n");
111+
return QUIC_STATUS_OUT_OF_MEMORY;
112+
}
109113
for (uint16_t i = 0; i < ProcCount; ++i) {
110114
if (!DelayWorkers[i].Initialize(this, i)) {
115+
for (uint16_t j = 0; j < i; ++j) {
116+
DelayWorkers[j].Shutdown();
117+
}
118+
delete[] DelayWorkers;
119+
DelayWorkers = nullptr;
111120
WriteOutput("Failed to init delay workers.\n");
112121
return QUIC_STATUS_INTERNAL_ERROR;
113122
}

0 commit comments

Comments
 (0)