From 7d5a7ef9cafb915170ad3dd1cd480192bcd15127 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Sun, 1 Mar 2015 12:48:08 +0530 Subject: [PATCH] main.c: Fix two potential memory leaks Reported by: Coverity bug 1188048 --- src/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index b23967bb..b59fcab4 100644 --- a/src/main.c +++ b/src/main.c @@ -875,7 +875,10 @@ format_and_print_line (const char *prefix, const char *line, line_dup = xstrdup (line); if (printf ("%s", prefix) < 0) - return -1; + { + xfree (line_dup); + return -1; + } /* Wrap to new line after prefix. */ remaining_chars = 0; @@ -903,7 +906,10 @@ format_and_print_line (const char *prefix, const char *line, } if (printf ("\n") < 0) - return -1; + { + xfree (line_dup); + return -1; + } xfree (line_dup); return 0;