valgrind: Clear more unfreed memory issues
[sigrok-cli.git] / parsers.c
index f7d03bc6bbf230d9af2247b11ecf1fd43755e27d..5ec655f78ad3dce8a05f01186a2a7ec61febb437 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -24,8 +25,6 @@
 #include <glib.h>
 #include "sigrok-cli.h"
 
-extern struct sr_context *sr_ctx;
-
 struct sr_channel *find_channel(GSList *channellist, const char *channelname)
 {
        struct sr_channel *ch;
@@ -410,12 +409,15 @@ int parse_driver(char *arg, struct sr_dev_driver **driver, GSList **drvopts)
        int i;
        char *drvname;
 
+       if (!arg)
+               return FALSE;
+
        drvargs = parse_generic_arg(arg, TRUE);
 
        drvname = g_strdup(g_hash_table_lookup(drvargs, "sigrok_key"));
        g_hash_table_remove(drvargs, "sigrok_key");
        *driver = NULL;
-       drivers = sr_driver_list();
+       drivers = sr_driver_list(sr_ctx);
        for (i = 0; drivers[i]; i++) {
                if (strcmp(drivers[i]->name, drvname))
                        continue;