[Archive] Close the dir object first, check for error later.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 22 Jun 2015 11:32:47 +0000 (13:32 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Mon, 22 Jun 2015 11:32:47 +0000 (13:32 +0200)
Prevent CID: 451196, 451231

[Verification] TCT pass rate: 100%

Change-Id: Ibc37601fed5147ecf4801e81ec53ef2b797e7b28
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/archive/filesystem_node.cc

index c00907a3b480fa475ddf65a266dda38da0043593..7c266d12722680b5e088ddc8febeae0fcddb3976 100755 (executable)
@@ -232,16 +232,17 @@ PlatformResult Node::getChildNames(Node::NameList* out_name_list) const
         }
         name_list.push_back(entry.d_name);
     }
-    if (0 != err) {
-        LoggerE("throw IOException");
-        return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory.");
-    }
 
     if (closedir(dir) != 0) {
         LoggerE("throw IOException");
         return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node.");
     }
 
+    if (0 != err) {
+        LoggerE("throw IOException");
+        return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory.");
+    }
+
     *out_name_list = name_list;
     return PlatformResult(ErrorCode::NO_ERROR);
 }
@@ -285,16 +286,16 @@ PlatformResult Node::getChildNodes(NodeList* out_node_list) const
         node_list.push_back(node);
     }
 
-    if (0 != err) {
+    if (closedir(dir) != 0) {
         LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
         LoggerE("throw IOException");
-        return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory.");
+        return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node.");
     }
 
-    if (closedir(dir) != 0) {
+    if (0 != err) {
         LoggerE("Path %s Perm %d", m_path->getFullPath().c_str(), m_perms);
         LoggerE("throw IOException");
-        return PlatformResult(ErrorCode::IO_ERR, "Could not close platform node.");
+        return PlatformResult(ErrorCode::IO_ERR, "Error while reading directory.");
     }
 
     *out_node_list = node_list;