mirror of https://github.com/vitalif/e2fsprogs
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>bitmap-optimize
parent
2bf0739dc0
commit
6d4ced2192
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue