From 890d03c15446ded944db11904d9a8bb04d9fe55a Mon Sep 17 00:00:00 2001 From: Ed Gonzalez Date: Thu, 5 Mar 2015 16:22:37 -0600 Subject: [PATCH] CID12103 and CID12096 - Fix minor leak when passing duplicate cfg_path and restrict_ip params --- DSP_API/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DSP_API/main.c b/DSP_API/main.c index 3b0e5de..07b1611 100644 --- a/DSP_API/main.c +++ b/DSP_API/main.c @@ -149,11 +149,20 @@ int main( int argc, char * argv[]) enable_console = TRUE; output(ANSI_YELLOW" WAVEFORM Version 1.0.3, Console alive.\n"ANSI_WHITE); } else if ( strncmp(argv[i], restrict_ip_param, strlen(restrict_ip_param)) == 0 ) { - + /* Free if param was passed in twice */ + if ( restrict_ip ) { + safe_free( restrict_ip ); + restrict_ip = NULL; + } restrict_ip = safe_malloc(strlen(argv[i])); strncpy(restrict_ip, argv[i]+strlen(restrict_ip_param), strlen(argv[i])); output("Restrict IP = '%s'\n", restrict_ip); } else if ( strncmp(argv[i], config_path_param ,strlen(config_path_param)) == 0 ) { + /* Free if param was passed in twice */ + if ( cfg_path ) { + safe_free( cfg_path ) ; + cfg_path = NULL; + } cfg_path = safe_malloc(strlen(argv[i])); strncpy(cfg_path, argv[i] + strlen(config_path_param), strlen(argv[i])); output("Config Path = '%s'\n", cfg_path);