[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 1/2] fish options parsing: Allow add_drives to be called multiple times.



From: "Richard W.M. Jones" <rjones redhat com>

Don't leak old drv->device when add_drives is called multiple times.
---
 fish/options.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fish/options.c b/fish/options.c
index 48c8e1c..f652389 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);
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]