From f9646a0c14cf8b8b172c33ca54c3d1fc77403ac3 Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Wed, 19 Nov 2014 23:39:22 +0530 Subject: [PATCH] Fix potential memory leak in main.c --- src/ChangeLog | 4 ++++ src/main.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index ef6ea7e5..9d6e2998 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-11-19 Darshit Shah + + * main.c (format_and_print_line): Fix potential memory leak + 2014-11-19 Darshit Shah * utils.c (compile_posix_regex): Fix memory leak due to unfreed regex diff --git a/src/main.c b/src/main.c index d00324dd..530f9e8e 100644 --- a/src/main.c +++ b/src/main.c @@ -891,7 +891,10 @@ format_and_print_line (const char *prefix, const char *line, remaining_chars = line_length - TABULATION; } if (printf ("%s ", token) < 0) - return -1; + { + xfree_null (line_dup); + return -1; + } remaining_chars -= strlen (token) + 1; /* account for " " */ token = strtok (NULL, " "); }