From e49eb0aaa7e0338c3824634e116da48e88ebb032 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 22 Mar 2021 17:00:41 +0100 Subject: [PATCH] virJSONValueObjectDeflattenWorker: use g_strsplit instead of virStringSplitCount MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The presence of the second element can be checked by looking at it directly. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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 0eff467ec5..d52b99e11b 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1964,7 +1964,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, '.')) { @@ -1989,10 +1988,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.47.2