From: poljar (Damir Jelić) Date: Wed, 30 Oct 2013 22:04:02 +0000 (+0100) Subject: sigrok-cli: Fix leaks in device_scan(). X-Git-Tag: sigrok-cli-0.5.0~79 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=49dbdb782e21dda3e9be242ddcc37f0bcd06f4a7;p=sigrok-cli.git sigrok-cli: Fix leaks in device_scan(). If a bogus driver name is specified on the command line or for some reason we fail to initialize a driver device_scan() leaks data. This patch adds appropriate free calls. --- diff --git a/sigrok-cli.c b/sigrok-cli.c index c60d3bb..dbe0b2c 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -178,11 +178,14 @@ static GSList *device_scan(void) } if (!driver) { g_critical("Driver %s not found.", drvname); + g_hash_table_destroy(drvargs); + g_free(drvname); return NULL; } g_free(drvname); if (sr_driver_init(sr_ctx, driver) != SR_OK) { g_critical("Failed to initialize driver."); + g_hash_table_destroy(drvargs); return NULL; } drvopts = NULL; @@ -193,7 +196,7 @@ static GSList *device_scan(void) return NULL; } } - g_hash_table_destroy(drvargs); + g_hash_table_destroy(drvargs); devices = sr_driver_scan(driver, drvopts); g_slist_free_full(drvopts, (GDestroyNotify)free_drvopts); } else {