Fix memory leak 13/244613/2
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 22 Sep 2020 09:51:10 +0000 (18:51 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 23 Sep 2020 01:52:27 +0000 (10:52 +0900)
xmlDocPtr allocated by xmlParseFile should be freed

Change-Id: Ife75f38f457ae2d19b680f40ced8440f4b9c4bee
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/tpk/step/pkgmgr/step_convert_xml.cc

index af824d7..9a1d1a5 100644 (file)
@@ -100,6 +100,8 @@ bool StepConvertXml::ConvertXml(xmlDocPtr doc) {
 
 common_installer::Step::Status StepConvertXml::process() {
   xmlDocPtr doc = xmlParseFile(xml_path_.string().c_str());
+  auto doc_ptr = std::unique_ptr<std::remove_pointer<xmlDocPtr>::type,
+      decltype(xmlFreeDoc)*>(doc, xmlFreeDoc);
   if (!doc) {
     LOG(ERROR) << "Failed to parse xml file";
     return Step::Status::MANIFEST_ERROR;