From 6172ef209382af85994ef2e871ef2cc2c379bf7c Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 12 Jun 2019 16:02:31 +0500 Subject: [PATCH] src/src/lookups/dnsdb.c: resolve possible null pointer dereference found by cppcheck [src/src/lookups/dnsdb.c:561] -> [src/src/lookups/dnsdb.c:552]: (warning) Either the condition '!yield' is redundant or there is possible null pointer dereference: yield. --- src/src/lookups/dnsdb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c index aea2eba720..c9ce315535 100644 --- a/src/src/lookups/dnsdb.c +++ b/src/src/lookups/dnsdb.c @@ -547,10 +547,6 @@ while ((domain = string_nextinlist(&keystring, &sep, NULL, 0))) } /* Loop for list of domains */ -/* Reclaim unused memory */ - -store_reset(yield->s + yield->ptr + 1); - /* If yield NULL we have not found anything. Otherwise, insert the terminating zero and return the result. */ @@ -560,6 +556,10 @@ dns_init(FALSE, FALSE, FALSE); /* clear the dnssec bit for getaddrbyname */ if (!yield || !yield->ptr) return failrc; +/* Reclaim unused memory */ + +store_reset(yield->s + yield->ptr + 1); + *result = string_from_gstring(yield); return OK; }