Page 1 of 1

[Nagios-devel] [PATCH 2/5] base/workers: Fix crash when freeing the

Posted: Mon Nov 05, 2012 1:59 pm
by Guest
From: Robin Sonefors

When freeing the last core worker, we'd set the worker list to NULL, yet
keep the list len at 1. This caused free_worker_memory to try to lookup
workers from NULL, creating a SEGFAULT.

By always decrementing len, even when we're destroying the last worker,
we'll actually realize that we're out of workers, leave NULL alone, and
shut down cleanly.

Signed-off-by: Robin Sonefors
---
base/workers.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/base/workers.c b/base/workers.c
index 2bc9765..0f33a8a 100644
--- a/base/workers.c
+++ b/base/workers.c
@@ -273,7 +273,8 @@ static int remove_specialized(void *data)
if (to_remove != NULL && list->wps != to_remove)
continue;

- if (list->len len--;
+ if (list->len wps);
list->wps = NULL;
if(list != &workers)
@@ -281,7 +282,6 @@ static int remove_specialized(void *data)
return DKHASH_WALK_REMOVE;
}
else {
- list->len--;
list->wps = list->wps[list->len];
i--;
}
--
1.7.11.7






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]