diff options
author | Eric Sandeen <sandeen@redhat.com> | 2011-09-16 15:49:40 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-16 19:55:55 -0400 |
commit | 30295f16a95b873965d1650b24fb6f5b82bde675 (patch) | |
tree | d4f0a883b2a18f4b169449e5cc4789dc240c0212 /misc/mke2fs.c | |
parent | 25726554ca557e22b96684d8a7ecf36ec80572a5 (diff) | |
download | e2fsprogs-30295f16a95b873965d1650b24fb6f5b82bde675.tar.gz |
mke2fs: free tdb_dir string if it came from the profile
if tdb_dir points to a string allocated from profile_get_string,
it should be freed again before we exit.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/mke2fs.c')
-rw-r--r-- | misc/mke2fs.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c index ff5d54bc..df694461 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -2024,18 +2024,21 @@ open_err_out: static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr) { errcode_t retval = ENOMEM; - char *tdb_dir, *tdb_file = NULL; + char *tdb_dir = NULL, *tdb_file = NULL; char *device_name, *tmp_name; + int free_tdb_dir = 0; /* * Configuration via a conf file would be * nice */ tdb_dir = getenv("E2FSPROGS_UNDO_DIR"); - if (!tdb_dir) + if (!tdb_dir) { profile_get_string(profile, "defaults", "undo_dir", 0, "/var/lib/e2fsprogs", &tdb_dir); + free_tdb_dir = 1; + } if (!strcmp(tdb_dir, "none") || (tdb_dir[0] == 0) || access(tdb_dir, W_OK)) @@ -2069,10 +2072,14 @@ static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr) "using the command:\n" " e2undo %s %s\n\n"), tdb_file, name); + if (free_tdb_dir) + free(tdb_dir); free(tdb_file); return 0; errout: + if (free_tdb_dir) + free(tdb_dir); free(tdb_file); com_err(program_name, retval, _("while trying to setup undo file\n")); |