From 96f93a79d986a6d92f663b9ee8cae00413503386 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Mon, 26 Dec 2022 13:27:03 +0300 Subject: [PATCH] [Core] Fix possible file descriptor and a memory leak in switch_xml_parse_file_simple(). --- src/switch_xml.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/switch_xml.c b/src/switch_xml.c index d54294df92..ab07ead06a 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1649,7 +1649,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file_simple(const char *file) int fd = -1; struct stat st; switch_ssize_t l; - void *m; + void *m = NULL; switch_xml_root_t root; if ((fd = open(file, O_RDONLY, 0)) > -1) { @@ -1680,6 +1680,11 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file_simple(const char *file) error: + switch_safe_free(m); + if (fd > -1) { + close(fd); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing File [%s]\n", file); return NULL; -- 2.47.3