]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FSCORE-608 (2nd issue pertaining to parsing an empty xml file)
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 14 May 2010 16:27:29 +0000 (11:27 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 14 May 2010 16:27:29 +0000 (11:27 -0500)
src/switch_xml.c

index 947a3060e9dad6f51a27444bfbe3bebc47b9bf76..8df8b77c069447f1ba46c881d5e211cbcb1af3dd 100644 (file)
@@ -1505,15 +1505,20 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file_simple(const char *file)
 
        if ((fd = open(file, O_RDONLY, 0)) > -1) {
                fstat(fd, &st);
+               if (!st.st_size) goto error;
                m = malloc(st.st_size);
                switch_assert(m);
-               l = read(fd, m, st.st_size);
-               root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l);
+               if (!(l = read(fd, m, st.st_size))) goto error;
+               if (!(root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l))) goto error;
                root->dynamic = 1;
                close(fd);
                return &root->xml;
        }
 
+ error:
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing File [%s]\n", file);
+
        return NULL;
 }