From cc0b3782f14067aabe719edff0d871a09fe25369 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 10 Apr 2019 16:49:16 +0200 Subject: [PATCH] Review comments 1 Signed-off-by: DL6ER --- resolve.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/resolve.c b/resolve.c index 7ff194d49..d45a1d1dc 100644 --- a/resolve.c +++ b/resolve.c @@ -99,10 +99,10 @@ void resolveClients(bool onlynew) lock_shm(); // Only store new hostname if it changed + // We do not need to check for name == NULL as name is + // always initialized with an empty string at position 0 if(hostname != NULL && strcmp(name, hostname) != 0) { - // We do not need to check for name == NULL as name is - // always initialized with an empty string at position 0 clients[clientID].namepos = addstr(hostname); } else if(config.debug & DEBUG_SHMEM) @@ -112,7 +112,8 @@ void resolveClients(bool onlynew) } // Release allocated memory - free(hostname); + if(hostname != NULL) + free(hostname); // Mark entry as not new clients[clientID].new = false; @@ -150,10 +151,10 @@ void resolveForwardDestinations(bool onlynew) // Finally, lock data when storing obtained hostname lock_shm(); // Only store new hostname if it changed + // We do not need to check for name == NULL as name is + // always initialized with an empty string at position 0 if(hostname != NULL && strcmp(name, hostname) != 0) { - // We do not need to check for name == NULL as name is - // always initialized with an empty string at position 0 forwarded[forwardID].namepos = addstr(hostname); } else if(config.debug & DEBUG_SHMEM) @@ -163,7 +164,8 @@ void resolveForwardDestinations(bool onlynew) } // Release allocated memory - free(hostname); + if(hostname != NULL) + free(hostname); // Mark entry as not new forwarded[forwardID].new = false;