From d64921848dbec07bf07d04b6ceaa6fed878f1381 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Feb 2020 16:35:15 +1100 Subject: [PATCH] cleanup error handling. 336 cleanup_mem: 337 /* cleanup memory */ 338 339 /* free tmpPath memory */ CID 1452701 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking tmpPath suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 340 if (tmpPath != NULL && result != ISC_R_SUCCESS) 341 isc_mem_free(named_g_mctx, tmpPath); 342 343 /* free tmpPath memory */ 344 return (result); --- contrib/dlz/drivers/dlz_filesystem_driver.c | 25 ++++----------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/contrib/dlz/drivers/dlz_filesystem_driver.c b/contrib/dlz/drivers/dlz_filesystem_driver.c index dbe15291d5..05ce2ef8c4 100644 --- a/contrib/dlz/drivers/dlz_filesystem_driver.c +++ b/contrib/dlz/drivers/dlz_filesystem_driver.c @@ -157,7 +157,7 @@ is_safe(const char *input) { return (true); } -static isc_result_t +static void create_path_helper(char *out, const char *in, config_data_t *cd) { char *tmpString; char *tmpPtr; @@ -206,7 +206,6 @@ create_path_helper(char *out, const char *in, config_data_t *cd) { } isc_mem_free(named_g_mctx, tmpString); - return (ISC_R_SUCCESS); } /*% @@ -223,7 +222,6 @@ create_path(const char *zone, const char *host, const char *client, char *tmpPath; int pathsize; int len; - isc_result_t result; bool isroot = false; /* we require a zone & cd parameter */ @@ -285,9 +283,7 @@ create_path(const char *zone, const char *host, const char *client, /* add zone name - parsed properly */ if (!isroot) { - result = create_path_helper(tmpPath, zone, cd); - if (result != ISC_R_SUCCESS) - goto cleanup_mem; + create_path_helper(tmpPath, zone, cd); } /* @@ -322,26 +318,13 @@ create_path(const char *zone, const char *host, const char *client, /* if host not null, add it. */ if (host != NULL) { strncat(tmpPath, (char *) &cd->pathsep, 1); - if ((result = create_path_helper(tmpPath, host, - cd)) != ISC_R_SUCCESS) - goto cleanup_mem; + create_path_helper(tmpPath, host, cd); } /* return the path we built. */ *path = tmpPath; - /* return success */ - result = ISC_R_SUCCESS; - - cleanup_mem: - /* cleanup memory */ - - /* free tmpPath memory */ - if (tmpPath != NULL && result != ISC_R_SUCCESS) - isc_mem_free(named_g_mctx, tmpPath); - - /* free tmpPath memory */ - return (result); + return (ISC_R_SUCCESS); } static isc_result_t