Page 1 of 1

[Nagios-devel] [PATCH 3/4] base/nerd: Fix crash during shutdown

Posted: Tue Nov 27, 2012 4:42 pm
by Guest
From: Robin Sonefors

If opathchecks had been used, the cleanup code didn't properly zero the
host_parent_path_cache pointer, meaning it would dangle and cause
crashes the next time it was used.

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

diff --git a/base/nerd.c b/base/nerd.c
index 05a0953..e0cf6a5 100644
--- a/base/nerd.c
+++ b/base/nerd.c
@@ -254,7 +254,7 @@ static int chan_service_checks(int cb, void *data)
return 0;
}

-static char **host_parent_path_cache;
+static char **host_parent_path_cache = NULL;
static const char *host_parent_path(host *leaf, char sep)
{
char *ret;
@@ -341,7 +341,7 @@ static int nerd_deinit(void)
for(i = 0; i < num_objects.hosts; i++) {
my_free(host_parent_path_cache);
}
- free(host_parent_path_cache);
+ my_free(host_parent_path_cache);
}

for(i = 0; i < num_channels; i++) {
--
1.7.11.7






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