From 58c1d83c9ed6af66f8f2606aa20df7076924836f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 5 Nov 2015 11:14:53 +0100 Subject: [PATCH] CID 22491 FORWARD_NULL github issue #352 fals positive, rewriting code to appease coverity --- src/util/crmessage.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util/crmessage.c b/src/util/crmessage.c index 942ba2610..d15228510 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -91,22 +91,21 @@ void crt_register(const struct message_type *mtype) crt = crt->next; } if (!crt) { - int i; crt = malloc(sizeof(crmessage_type)); crt->mtype = mtype; crt->next = crtypes[hash]; crtypes[hash] = crt; if (mtype->nparameters > 0) { + int i; crt->renderers = malloc(sizeof(tostring_f) * mtype->nparameters); + /* can be scrapped for memory vs. speed */ + for (i = 0; i != mtype->nparameters; ++i) { + crt->renderers[i] = tsf_find(mtype->types[i]->name); + } } else { crt->renderers = NULL; } - - /* can be scrapped for memory vs. speed */ - for (i = 0; i != mtype->nparameters; ++i) { - crt->renderers[i] = tsf_find(mtype->types[i]->name); - } } }