FSCORE-608 (2nd issue pertaining to parsing an empty xml file)
This commit is contained in:
parent
349abc3fd0
commit
9da349213b
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue