From 249df0176aec9a31e485bfa7464da8818d970398 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 4 Mar 2024 11:59:12 +0000 Subject: [PATCH] - fixed potential memory leak when GooseReceiver is immediately stopped after start (I6PLLCV-71) --- src/goose/goose_receiver.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/goose/goose_receiver.c b/src/goose/goose_receiver.c index 63fe97107..164ddca8a 100644 --- a/src/goose/goose_receiver.c +++ b/src/goose/goose_receiver.c @@ -1014,9 +1014,12 @@ gooseReceiverLoop(void *threadParameter) EthernetHandleSet handleSet = EthernetHandleSet_new(); EthernetHandleSet_addSocket(handleSet, self->ethSocket); - if (self->running) { + bool running = true; - while (self->running) { + if (running) + { + while (running) + { switch (EthernetHandleSet_waitReady(handleSet, 100)) { case -1: @@ -1030,6 +1033,8 @@ gooseReceiverLoop(void *threadParameter) } if (self->stop) break; + + running = self->running; } GooseReceiver_stopThreadless(self); @@ -1046,7 +1051,8 @@ void GooseReceiver_start(GooseReceiver self) { #if (CONFIG_MMS_THREADLESS_STACK == 0) - if (GooseReceiver_startThreadless(self)) { + if (GooseReceiver_startThreadless(self)) + { self->thread = Thread_create((ThreadExecutionFunction) gooseReceiverLoop, (void*) self, false); if (self->thread != NULL) {