write_sensu: fix resource leaks on error
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 2 Apr 2016 13:53:15 +0000 (15:53 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 2 Apr 2016 14:06:40 +0000 (16:06 +0200)
Fixes CID #37998

src/write_sensu.c

index 5e231a5..c427467 100644 (file)
@@ -192,6 +192,7 @@ static char *build_json_str_list(const char *tag, struct str_list const *list) /
        res = asprintf(&temp_str, "\"%s\": [\"%s\"", tag, list->strs[0]);
        if (res == -1) {
                ERROR("write_sensu plugin: Unable to alloc memory");
+               free(ret_str);
                return NULL;
        }
        for (i=1; i<list->nb_strs; i++) {