From 21553b6e240e6a66ab6a659343073621d3c09864 Mon Sep 17 00:00:00 2001 From: MadVitaliy Date: Fri, 2 Aug 2024 12:05:12 +0000 Subject: [PATCH] fix -Wuse-after-free --- Utilities/socketxx/socket++/fork.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Utilities/socketxx/socket++/fork.cpp b/Utilities/socketxx/socket++/fork.cpp index 4b580aa1f8..9838c2bc82 100644 --- a/Utilities/socketxx/socket++/fork.cpp +++ b/Utilities/socketxx/socket++/fork.cpp @@ -38,9 +38,12 @@ Fork::KillForks::~KillForks () // First, kill all children whose kill_child flag is set. // Second, wait for other children to die. { - for (ForkProcess* cur = Fork::ForkProcess::list; cur; cur = cur->next) - if (cur->kill_child) + + for (ForkProcess* cur = Fork::ForkProcess::list; cur != nullptr; cur = cur->next) + if (cur->kill_child) { delete cur; + break; + } while (Fork::ForkProcess::list && wait (nullptr) > 0) {} }