浏览代码

fix memory leak in read_config_file

Thibaut Ackermann 7 年之前
父节点
当前提交
58947cc531
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/apps/relay/mainrelay.c

+ 6 - 1
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;
+		}
 	}
 }