From d611622b231a63615c23b4273aea599539b03078 Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Wed, 5 Nov 2014 15:21:17 +0200 Subject: [PATCH] Fix to Coverity issue 72738, passed NULL-pointer to a function which referenced it. --- server/core/gateway.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index 8f0c6d705..f6b7a18fa 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -479,6 +479,11 @@ static bool resolve_maxscale_conf_fname( goto return_succp; } } + else + { + /** Allocate memory for use of realpath */ + *cnf_full_path = (char *)malloc(PATH_MAX+1); + } /*< * 3. argument is valid relative pathname * '-f ../myconf.cnf' @@ -1704,11 +1709,7 @@ int main(int argc, char **argv) for (n = 0; n < n_threads - 1; n++) { thread_wait(threads[n]); - } - free(threads); - free(home_dir); - free(cnf_file_path); - + } /*< * Wait the flush thread. */ @@ -1732,6 +1733,10 @@ int main(int argc, char **argv) unlink_pidfile(); return_main: + free(threads); + free(home_dir); + free(cnf_file_path); + return rc; } /*< End of main */