From 58947cc531c62c32bc34ef212347c583bb7d2444 Mon Sep 17 00:00:00 2001 From: Thibaut Ackermann Date: Tue, 2 Oct 2018 15:28:37 +0200 Subject: [PATCH 1/2] fix memory leak in read_config_file --- src/apps/relay/mainrelay.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/apps/relay/mainrelay.c b/src/apps/relay/mainrelay.c index 66e2bab..c4689f3 100644 --- a/src/apps/relay/mainrelay.c +++ b/src/apps/relay/mainrelay.c @@ -1604,7 +1604,7 @@ static void read_config_file(int argc, char **argv, int pass) if (full_path_to_config_file) f = fopen(full_path_to_config_file, "r"); - if (f && full_path_to_config_file) { + if (f) { char sbuf[1025]; char sarg[1035]; @@ -1653,6 +1653,11 @@ static void read_config_file(int argc, char **argv, int pass) } else TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "WARNING: Cannot find config file: %s. Default and command-line settings will be used.\n", config_file); + + if (full_path_to_config_file) { + free(full_path_to_config_file); + full_path_to_config_file = NULL; + } } } From ea0eadabde4d30b394f9efa1536eecd547e87e98 Mon Sep 17 00:00:00 2001 From: Thibaut Ackermann Date: Thu, 4 Oct 2018 09:58:45 +0200 Subject: [PATCH 2/2] use turn_free instead of free to fix memory leak in read_config_file --- src/apps/relay/mainrelay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/relay/mainrelay.c b/src/apps/relay/mainrelay.c index c4689f3..dea7ec4 100644 --- a/src/apps/relay/mainrelay.c +++ b/src/apps/relay/mainrelay.c @@ -1655,7 +1655,7 @@ static void read_config_file(int argc, char **argv, int pass) config_file); if (full_path_to_config_file) { - free(full_path_to_config_file); + turn_free(full_path_to_config_file, strlen(full_path_to_config_file)+1); full_path_to_config_file = NULL; } }