]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
examples/librados: avoid a memory leak 43208/head
authorInjae Kang <abcinje@gmail.com>
Fri, 17 Sep 2021 15:42:41 +0000 (00:42 +0900)
committerInjae Kang <abcinje@gmail.com>
Sat, 18 Sep 2021 06:16:55 +0000 (15:16 +0900)
Avoid a memory leak by deallocating the pre-allocated aio completion.

Signed-off-by: Injae Kang <abcinje@gmail.com>
examples/librados/hello_world.cc

index 759e26966e9e7b0005cfef1174eb0c913f006566..3607311c1b3ed7cfddc401b222033484db821d10 100644 (file)
@@ -156,6 +156,7 @@ int main(int argc, const char **argv)
     if (ret < 0) {
       std::cerr << "couldn't start read object! error " << ret << std::endl;
       ret = EXIT_FAILURE;
+      read_completion->release();
       goto out;
     }
     // wait for the request to complete, and check that it succeeded.
@@ -164,6 +165,7 @@ int main(int argc, const char **argv)
     if (ret < 0) {
       std::cerr << "couldn't read object! error " << ret << std::endl;
       ret = EXIT_FAILURE;
+      read_completion->release();
       goto out;
     }
     std::cout << "we read our object " << object_name
@@ -171,6 +173,7 @@ int main(int argc, const char **argv)
     std::string read_string;
     read_buf.begin().copy(ret, read_string);
     std::cout << read_string << std::endl;
+    read_completion->release();
   }
 
   /*