diff options
author | Eric Sandeen <sandeen@redhat.com> | 2011-09-16 15:49:36 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-16 19:55:55 -0400 |
commit | 6d4ced2192766f09f021ed801797961ad2f8e258 (patch) | |
tree | 2018403085affdb444b675ac75cea7d1b08d2710 /e2fsck/profile.c | |
parent | 2bf0739dc040099f1ce6ac03ea6d9a2781aef734 (diff) | |
download | e2fsprogs-6d4ced2192766f09f021ed801797961ad2f8e258.tar.gz |
e2fsck: Fix leaks in error paths
fn and/or array was not freed in some error paths.
[ Also make sure the array is NULL terminated before we free it in
get_dirlist(). --tytso]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck/profile.c')
-rw-r--r-- | e2fsck/profile.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/e2fsck/profile.c b/e2fsck/profile.c index 327bfb48..f4267b14 100644 --- a/e2fsck/profile.c +++ b/e2fsck/profile.c @@ -276,6 +276,7 @@ static errcode_t get_dirlist(const char *dirname, char***ret_array) new_array = realloc(array, sizeof(char *) * (max+1)); if (!new_array) { retval = ENOMEM; + free(fn); goto errout; } array = new_array; @@ -290,6 +291,8 @@ static errcode_t get_dirlist(const char *dirname, char***ret_array) closedir(dir); return 0; errout: + if (array) + array[num] = 0; closedir(dir); free_list(array); return retval; @@ -345,8 +348,8 @@ profile_init(const char **files, profile_t *ret_profile) * If all the files were not found, return the appropriate error. */ if (!profile->first_file) { - profile_release(profile); - return ENOENT; + retval = ENOENT; + goto errout; } } |