Skip to content

Commit

Permalink
fix -Wuse-after-free
Browse files Browse the repository at this point in the history
  • Loading branch information
MadVitaliy committed Aug 2, 2024
1 parent 19c43b9 commit 21553b6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Utilities/socketxx/socket++/fork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
Expand Down

0 comments on commit 21553b6

Please sign in to comment.