From cae542ce8e79403d9b3c0df4e4b7b75d03f996b6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 28 Mar 2007 11:28:24 -0400 Subject: [PATCH] [COVERITY] Fix memory leak when parsing extended options in e2fsck Coverity ID: 35: Resource Leak Signed-off-by: Brian Behlendorf --- e2fsck/ChangeLog | 4 ++++ e2fsck/unix.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 8d5e491..7dbd05a 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,7 @@ +2007-03-28 Theodore Tso + + * unix.c (parse_extended_opts): Fix memory leak + 2007-03-21 Theodore Tso * profile.c (profile_open_file): Fix memory leak if malloc() fails diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 898bc33..7631c14 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -523,7 +523,7 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts) if (p) { *p = 0; next = p+1; - } + } arg = strchr(token, '='); if (arg) { *arg = 0; @@ -549,6 +549,8 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts) extended_usage++; } } + free(buf); + if (extended_usage) { fputs(("\nExtended options are separated by commas, " "and may take an argument which\n" @@ -557,7 +559,7 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts) "\tea_ver=\n\n"), stderr); exit(1); } -} +} static void syntax_err_report(const char *filename, long err, int line_num) { -- 1.8.3.1