From: Gerhard Sittig Date: Tue, 30 Aug 2022 22:40:37 +0000 (+0200) Subject: parsers: avoid NULL dereference when option strings are empty X-Git-Url: http://sigrok.org/gitweb/?p=sigrok-cli.git;a=commitdiff_plain;h=af9fa8c5ea9925cb8fe076ae7d4e996836a6db13 parsers: avoid NULL dereference when option strings are empty When colon separated options are scanned (like "-P ps2: --show") then the empty list item which results from the trailing colon resulted in key/value pairs becoming NULL. Handle that situation, skip empty list elements. Reported-By: Peter Mortensen via IRC --- diff --git a/parsers.c b/parsers.c index b74d74f..59a7a91 100644 --- a/parsers.c +++ b/parsers.c @@ -364,6 +364,8 @@ GHashTable *parse_generic_arg(const char *arg, i++; } for (; elements[i]; i++) { + if (!elements[i][0]) + continue; split_key_value(elements[i], &k, &v); k = g_strdup(k); v = v ? g_strdup(v) : NULL;