From 5790fee9a0322f570cd68c568deb40dd8f7403cc Mon Sep 17 00:00:00 2001 From: James Jones Date: Tue, 3 Dec 2024 17:18:47 -0600 Subject: [PATCH] Move coverity-only check ahead of first use (CID #1635782) The check that dctx->dict is non-NULL has to appear before the first dereference of dctx->dict. --- src/lib/util/dict_tokenize.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index af8209155995..9bc89daf2d57 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -1916,6 +1916,10 @@ static int dict_read_process_enum(dict_tokenize_ctx_t *dctx, char **argv, int ar return -1; } +#ifdef STATIC_ANALYZER + if (!dctx->dict) goto error; +#endif + /* * Allocate the attribute here, and then fill in the fields * as we start parsing the various elements of the definition. @@ -1971,10 +1975,6 @@ static int dict_read_process_enum(dict_tokenize_ctx_t *dctx, char **argv, int ar * Maybe we do want a flag field for named time deltas? */ -#ifdef STATIC_ANALYZER - if (!dctx->dict) goto error; -#endif - if (unlikely(dict_attr_parent_init(&da, parent) < 0)) goto error; if (unlikely(dict_attr_finalise(&da, argv[0]) < 0)) goto error;