summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Gupta <g.gupta@samsung.com>2020-02-17 11:08:45 +0530
committersanghyeok oh <sanghyeok.oh@samsung.com>2020-03-27 03:58:39 +0000
commitdd569bc52ec74de77b78b6d744e405f3e4c6ad7c (patch)
tree5b1a57c7683619df1d538c525415c4cc796e4c08
parentb8099d58e61720f2c0612aef43d74c1d9f101a7d (diff)
downloadlibdbuspolicy-dd569bc52ec74de77b78b6d744e405f3e4c6ad7c.tar.gz
libdbuspolicy-dd569bc52ec74de77b78b6d744e405f3e4c6ad7c.tar.bz2
libdbuspolicy-dd569bc52ec74de77b78b6d744e405f3e4c6ad7c.zip
Fix memleak issue reported by Dexter tool.
Change-Id: I24e2d2d6b6ecb3e3daf0edd94fe67866f369e87a
-rw-r--r--src/internal/xml_parser.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/internal/xml_parser.cpp b/src/internal/xml_parser.cpp
index 62d8372..dba29ff 100644
--- a/src/internal/xml_parser.cpp
+++ b/src/internal/xml_parser.cpp
@@ -223,16 +223,20 @@ std::unique_ptr<char[]> file2str(const char *filename) {
}
if (fseek(fp, 0, SEEK_END)) {
+ fclose(fp);
throw std::runtime_error(std::string("Failed to fseek end of file").c_str());
}
long fsize = ftell(fp);
if (fsize < 0) {
+ fclose(fp);
throw std::runtime_error(std::string("Failed to ftell").c_str());
}
if (fsize > (MAX_CONF_SIZE)) {
+ fclose(fp);
throw std::runtime_error(std::string("File size over ").append(std::to_string(MAX_CONF_SIZE)).append("Bytes").c_str());
}
if (fseek(fp, 0, SEEK_SET)) {
+ fclose(fp);
throw std::runtime_error(std::string("Failed to fseek beginning of file").c_str());
}