mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
[core] Coverity fixes
* [core] Coverity CID 1468218 (Resource leak) * [core] Coverity CID 1468214 (Resource leak) * [core] Coverity CID 1294472 (Resource leak) * [core] Coverity CID 1294470 (Resource leak) * [core] Coverity CID 1500361 (Resource leak) * [core] Coverity CID 1500308 (Resource leak) * [core] Coverity CID 1500278 (Resource leak) --------- Co-authored-by: Andrey Volk <andywolk@gmail.com>
This commit is contained in:
+17
-3
@@ -1638,11 +1638,25 @@ 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;
|
||||
if (!st.st_size) {
|
||||
close(fd);
|
||||
goto error;
|
||||
}
|
||||
|
||||
m = switch_must_malloc(st.st_size);
|
||||
|
||||
if (!(0<(l = read(fd, m, st.st_size)))) goto error;
|
||||
if (!(root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l))) goto error;
|
||||
if (!(0 < (l = read(fd, m, st.st_size)))) {
|
||||
free(m);
|
||||
close(fd);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(root = (switch_xml_root_t)switch_xml_parse_str((char*)m, l))) {
|
||||
free(m);
|
||||
close(fd);
|
||||
goto error;
|
||||
}
|
||||
|
||||
root->dynamic = 1;
|
||||
close(fd);
|
||||
return &root->xml;
|
||||
|
||||
Reference in New Issue
Block a user