[Coverity] Resolve some coverity issues
authorDongju Chae <dongju.chae@samsung.com>
Mon, 22 Feb 2021 06:26:56 +0000 (15:26 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 22 Feb 2021 07:10:28 +0000 (16:10 +0900)
This patch resolves some coverity issues.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
src/core/npu/NPUdrvAPI_emul.cc
tests/apptests/tvn_triv2_bulk.cc

index a41b7e1..99402fa 100644 (file)
@@ -746,6 +746,8 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
     if (length == 0) {
       std::cerr << "Zero length detected at ";
       std::cerr << id << "th node" << std::endl;
+
+      delete [] new_layers;
       return;
     }
 
@@ -816,6 +818,8 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
 
     profile->layers = new_layers;
     profile->num_layers = num_layers + 1;
+  } else {
+    delete [] new_layers;
   }
 }
 
index 838042f..56a09fe 100644 (file)
@@ -74,6 +74,8 @@ main (int argc, char **argv)
   char * dir_str;
   int status;
 
+  std::ios_base::fmtflags f (cerr.flags ());
+
   status = tester.parseArgs (argc, argv, &dir_str, "[models' dir]");
   if (status == test_ret_skipped || dir_str == nullptr) {
     cerr << "[APPTEST] " << argv[0] << ": SKIPPED\n";
@@ -126,5 +128,7 @@ main (int argc, char **argv)
   cerr << "[APPTEST] " << argv[0] << ": PASSED (" << total_succs << "), "
        << "FAILED (" << total_fails << ")\n";
 
+  cerr.flags (f);
+
   return 0;
 }