Patchwork [21/25] e2fsck: Fix leaks in error paths

login
register
mail settings
Submitter Eric Sandeen
Date Sept. 16, 2011, 8:49 p.m.
Message ID <1316206180-6375-22-git-send-email-sandeen@redhat.com>
Download mbox | patch
Permalink /patch/115046/
State Accepted
Headers show

Comments

Eric Sandeen - Sept. 16, 2011, 8:49 p.m.
fn and/or array was not freed in some error paths.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 e2fsck/profile.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Patch

diff --git a/e2fsck/profile.c b/e2fsck/profile.c
index 327bfb4..c790623 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;
@@ -345,6 +346,7 @@  profile_init(const char **files, profile_t *ret_profile)
 	     * If all the files were not found, return the appropriate error.
 	     */
 	    if (!profile->first_file) {
+		free_list(array);
 		profile_release(profile);
 		return ENOENT;
 	    }