From: Theodore Ts'o Date: Wed, 12 Nov 2025 02:33:30 +0000 (-0500) Subject: mke2fs: fix memory leak which causes ASAN to complain X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=thirdparty%2Fe2fsprogs.git mke2fs: fix memory leak which causes ASAN to complain Fixes: 06f50e001b7d ("mke2fs: support multiple '-E' options") Signed-off-by: Theodore Ts'o --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 54c0f319..dd8c53d9 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1351,6 +1351,15 @@ static errcode_t init_list(struct str_list *sl) return 0; } +static void free_strlist(char **list) +{ + int i; + + for (i=0; list[i]; i++) + free(list[i]); + free(list); +} + static errcode_t push_string(struct str_list *sl, const char *str) { char **new_list; @@ -2673,6 +2682,7 @@ profile_error: /* Get options from commandline */ for (cpp = extended_opts.list; *cpp; cpp++) parse_extended_opts(&fs_param, *cpp); + free_strlist(extended_opts.list); if (fs_param.s_rev_level == EXT2_GOOD_OLD_REV) { if (fs_features) { @@ -3764,8 +3774,6 @@ no_journal: remove_error_table(&et_ext2_error_table); remove_error_table(&et_prof_error_table); profile_release(profile); - for (i=0; fs_types[i]; i++) - free(fs_types[i]); - free(fs_types); + free_strlist(fs_types); return retval; }