diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2010-09-21 19:40:23 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-09-21 19:51:22 +0100 |
commit | 8ea62c8d7f3f7f7e4057b93105cf979271aa13f4 (patch) | |
tree | 7bf525e6617ddc2f858513cd935222ae2f7b5679 /fish/prep.c | |
parent | e7f62742b6141fd19444fc0e191281777cd966f9 (diff) | |
download | libguestfs-8ea62c8d7f3f7f7e4057b93105cf979271aa13f4.tar.gz libguestfs-8ea62c8d7f3f7f7e4057b93105cf979271aa13f4.tar.xz libguestfs-8ea62c8d7f3f7f7e4057b93105cf979271aa13f4.zip |
leak: Free list of drives and mountpoints in guestfish.
Previously the list of -a, -d, -m, -N parameters were leaked. This
change frees them explicitly.
This is not such an important fix since guestfish is a one-shot
program, but it aids in finding other leaks in future.
(Found by valgrind).
Diffstat (limited to 'fish/prep.c')
-rw-r--r-- | fish/prep.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fish/prep.c b/fish/prep.c index 8b830719..9a6b64ed 100644 --- a/fish/prep.c +++ b/fish/prep.c @@ -116,7 +116,7 @@ Use 'guestfish -N help' to list possible values for the -N parameter.\n"), } for (i = 0; i < data->prep->nr_params; ++i) - data->params[i] = data->prep->params[i].pdefault; + data->params[i] = bad_cast (data->prep->params[i].pdefault); /* Parse the optional parameters. */ const char *p = type_string + len; @@ -167,3 +167,15 @@ prep_error (prep_data *data, const char *filename, const char *fs, ...) exit (EXIT_FAILURE); } + +void +free_prep_data (prep_data *data) +{ + size_t i; + + for (i = 0; i < data->prep->nr_params; ++i) + if (data->params[i] != data->prep->params[i].pdefault) + free (data->params[i]); + free (data->params); + free (data); +} |