From a850c51972ef63605de7b3dc9a95cf2a766c7621 Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sat, 5 Dec 2015 11:47:46 +0100 Subject: [PATCH] write_sensu plugin: fix two resource leaks on error CID #37999 Signed-off-by: Florian Forster --- src/write_sensu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/write_sensu.c b/src/write_sensu.c index f7803e86..507018fd 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -680,6 +680,7 @@ static char *sensu_notification_to_json(struct sensu_host *host, /* {{{ */ char *handlers_str = build_json_str_list("handlers", &(host->notification_handlers)); if (handlers_str == NULL) { ERROR("write_sensu plugin: Unable to alloc memory"); + free(ret_str); return NULL; } // incorporate the handlers @@ -781,6 +782,7 @@ static char *sensu_notification_to_json(struct sensu_host *host, /* {{{ */ char *msg = replace_json_reserved(n->message); if (msg == NULL) { ERROR("write_sensu plugin: Unable to alloc memory"); + free(ret_str); return NULL; } res = asprintf(&temp_str, "%s, \"output\": \"%s - %s\"", ret_str, severity, msg); -- 2.30.2