]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore/test_idempotent_sequence.cc: fix FileStore leaks
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 13 May 2013 10:45:03 +0000 (12:45 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 14 May 2013 16:39:30 +0000 (18:39 +0200)
CID 717107 (#1 of 1): Resource leak (RESOURCE_LEAK)
  leaked_storage: Variable "store" going out of scope leaks the
  storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/test/filestore/test_idempotent_sequence.cc

index 818a2554c352844a8f3dcc89f88e523305cda90a..d8f8c33ab51664099541a6b5b3c51d2044f0bd2a 100644 (file)
@@ -91,6 +91,8 @@ int run_diff(std::string& a_path, std::string& a_journal,
     dout(0) << "no diff" << dendl;
   }
 
+  delete a;
+  delete b;
   return ret;
 }
 
@@ -99,8 +101,10 @@ int run_get_last_op(std::string& filestore_path, std::string& journal_path)
   FileStore *store = new FileStore(filestore_path, journal_path);
 
   int err = store->mount();
-  if (err)
+  if (err) {
+    delete store;
     return err;
+  }
 
   coll_t txn_coll("meta");
   hobject_t txn_object(sobject_t("txn", CEPH_NOSNAP));
@@ -135,6 +139,7 @@ int run_sequence_to(int val, std::string& filestore_path,
   err = ::mkdir(filestore_path.c_str(), 0755);
   if (err) {
     cerr << filestore_path << " already exists" << std::endl;
+    delete store;
     return err;
   }
   
@@ -149,6 +154,7 @@ int run_sequence_to(int val, std::string& filestore_path,
   op_sequence.generate(seed, num_txs);
   store->umount();
 
+  delete store;
   return 0;
 }