]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Core] Fix possible file descriptor and a memory leak in switch_xml_parse_file_simple(). switch_xml_parse_file_simple 1901/head
authorAndrey Volk <andywolk@gmail.com>
Mon, 26 Dec 2022 10:27:03 +0000 (13:27 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 26 Dec 2022 10:27:03 +0000 (13:27 +0300)
src/switch_xml.c

index c43a530252e5c5f6ecfa2b1520c5bf66e5bffb5a..57bf99c8b6fccaa21f7a5deea1de4b01200615a5 100644 (file)
@@ -1633,7 +1633,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) {
@@ -1650,6 +1650,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;