summaryrefslogtreecommitdiffstats
path: root/fish/options.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-01-17 18:28:44 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-01-18 16:28:10 +0000
commitdd0707be5f9153a78ea0a07ec72f4e1f341a38c9 (patch)
treeee6806b89a42383a4da35310830bb71fc344b826 /fish/options.c
parentfd1a6d8003b29eaec5230f838f673df7cd0e9c86 (diff)
downloadlibguestfs-dd0707be5f9153a78ea0a07ec72f4e1f341a38c9.tar.gz
libguestfs-dd0707be5f9153a78ea0a07ec72f4e1f341a38c9.tar.xz
libguestfs-dd0707be5f9153a78ea0a07ec72f4e1f341a38c9.zip
fish options parsing: Allow add_drives to be called multiple times.
Ensure that the drv structure is always zeroed on allocation. Don't leak old drv->device when add_drives is called multiple times.
Diffstat (limited to 'fish/options.c')
-rw-r--r--fish/options.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fish/options.c b/fish/options.c
index 48c8e1c2..f6523898 100644
--- a/fish/options.c
+++ b/fish/options.c
@@ -43,6 +43,9 @@ add_drives (struct drv *drv, char next_drive)
if (drv) {
next_drive = add_drives (drv->next, next_drive);
+ free (drv->device);
+ drv->device = NULL;
+
if (asprintf (&drv->device, "/dev/sd%c", next_drive) == -1) {
perror ("asprintf");
exit (EXIT_FAILURE);