From: Sebastian Harl Date: Sun, 27 Jan 2008 22:26:41 +0000 (+0100) Subject: exec plugin: Fixed a possible (though very improbable) memory leak. X-Git-Tag: collectd-4.3.0beta0~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7970eb6191de2ff6f98a4d8cab73b55dd1d4b541;p=collectd.git exec plugin: Fixed a possible (though very improbable) memory leak. In case of an error, the program_list_and_notification_t pointer has not been freed before calling pthread_exit() from exec_notification_one(). Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- diff --git a/src/exec.c b/src/exec.c index e7648bd7..d5a8d0fd 100644 --- a/src/exec.c +++ b/src/exec.c @@ -581,8 +581,10 @@ static void *exec_notification_one (void *arg) /* {{{ */ const char *severity; pid = fork_child (pl, &fd, NULL); - if (pid < 0) + if (pid < 0) { + sfree (arg); pthread_exit ((void *) 1); + } fh = fdopen (fd, "w"); if (fh == NULL) @@ -593,6 +595,7 @@ static void *exec_notification_one (void *arg) /* {{{ */ kill (pl->pid, SIGTERM); pl->pid = 0; close (fd); + sfree (arg); pthread_exit ((void *) 1); }