The presence of the second element can be checked by looking at it directly. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/util/virjson.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 82081db870..f376490288 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -2029,7 +2029,6 @@ virJSONValueObjectDeflattenWorker(const char *key, g_autoptr(virJSONValue) newval = NULL; virJSONValuePtr existobj; g_auto(GStrv) tokens = NULL; - size_t ntokens = 0; /* non-nested keys only need to be copied */ if (!strchr(key, '.')) { @@ -2054,10 +2053,10 @@ virJSONValueObjectDeflattenWorker(const char *key, return 0; } - if (!(tokens = virStringSplitCount(key, ".", 2, &ntokens))) + if (!(tokens = g_strsplit(key, ".", 2))) return -1; - if (ntokens != 2) { + if (!tokens[0] || !tokens[1]) { virReportError(VIR_ERR_INVALID_ARG, _("invalid nested value key '%s'"), key); return -1; -- 2.29.2