parsers: avoid NULL dereference when option strings are empty master
authorGerhard Sittig <gerhard.sittig@gmx.net>
Tue, 30 Aug 2022 22:40:37 +0000 (00:40 +0200)
committerGerhard Sittig <gerhard.sittig@gmx.net>
Tue, 30 Aug 2022 23:16:19 +0000 (01:16 +0200)
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
parsers.c

index b74d74fe98792ac314094be4bf927b1e11b51fb3..59a7a91830220f573d7dd9abb85789fc0b038884 100644 (file)
--- 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;