log: fix memory leak when log to file is enabled

When log to file is enabled, the file is not closed by OpenOCD at
exit. This is reported by Valgrind as a memory leak that is still
reachable, as the internal buffers of 'FILE *log_output' are freed
by the automatic fclose() at exit.

Close the log file before exit.

Change-Id: Id472c0d04462035254a9b49ecb0a4037263c6f6f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6789
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2021-12-24 15:15:18 +01:00
parent 1536e249f2
commit 492ac453ab
3 changed files with 12 additions and 0 deletions

View File

@@ -437,6 +437,8 @@ int openocd_main(int argc, char *argv[])
rtt_exit();
free_config();
log_exit();
if (ret == ERROR_FAIL)
return EXIT_FAILURE;
else if (ret != ERROR_OK)