finddev.c (scan_dir): Fix memory leak; we weren't calling

closedir() when exiting the function in all cases.
bitmap-optimize
Theodore Ts'o 2001-07-29 12:01:09 -04:00
parent 1e16526bd9
commit 3751721fbb
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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;
}