diff options
author | Theodore Ts'o <tytso@mit.edu> | 2001-07-29 12:01:09 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2001-07-29 12:01:09 -0400 |
commit | 3751721fbb2b72cf99dff3755249357ef5372205 (patch) | |
tree | 2c6648b1d35ed687ee0066cc85c0d6436e78ce1d | |
parent | 1e16526bd9d7d14daf4bac46e1c6a3139182ba94 (diff) | |
download | android_external_e2fsprogs-3751721fbb2b72cf99dff3755249357ef5372205.tar.gz android_external_e2fsprogs-3751721fbb2b72cf99dff3755249357ef5372205.tar.bz2 android_external_e2fsprogs-3751721fbb2b72cf99dff3755249357ef5372205.zip |
finddev.c (scan_dir): Fix memory leak; we weren't calling
closedir() when exiting the function in all cases.
-rw-r--r-- | lib/ext2fs/ChangeLog | 5 | ||||
-rw-r--r-- | lib/ext2fs/finddev.c | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 90056882..0c28ed46 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,8 @@ +2001-07-29 Theodore Tso <tytso@valinux.com> + + * finddev.c (scan_dir): Fix memory leak; we weren't calling + closedir() when exiting the function in all cases. + 2001-07-27 Theodore Tso <tytso@valinux.com> * mkjournal.c (ext2fs_create_journal_superblock): Set the first diff --git a/lib/ext2fs/finddev.c b/lib/ext2fs/finddev.c index 5d85324c..2e9d70a4 100644 --- a/lib/ext2fs/finddev.c +++ b/lib/ext2fs/finddev.c @@ -101,15 +101,18 @@ static int scan_dir(char *dirname, dev_t device, struct dir_list **list, add_to_dirlist(path, list); if (S_ISBLK(st.st_mode) && st.st_rdev == device) { cp = malloc(strlen(path)+1); - if (!cp) + if (!cp) { + closedir(dir); return ENOMEM; + } strcpy(cp, path); *ret_path = cp; - return 0; + goto success; } skip_to_next: dp = readdir(dir); } +success: closedir(dir); return 0; } |