From dd0707be5f9153a78ea0a07ec72f4e1f341a38c9 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 17 Jan 2012 18:28:44 +0000 Subject: 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. --- fish/options.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fish/options.c') 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); -- cgit