[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:
Jakub Karolczyk
2023-03-31 22:07:59 +01:00
committed by GitHub
parent 04dd67da00
commit 49c1c35982
8 changed files with 49 additions and 20 deletions
+17 -3
View File
@@ -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;