From: Injae Kang Date: Fri, 17 Sep 2021 15:42:41 +0000 (+0900) Subject: examples/librados: avoid a memory leak X-Git-Tag: v17.1.0~855^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=acc929a0b9c19df917c60cc11c5a9635242d5844;p=ceph.git examples/librados: avoid a memory leak Avoid a memory leak by deallocating the pre-allocated aio completion. Signed-off-by: Injae Kang --- diff --git a/examples/librados/hello_world.cc b/examples/librados/hello_world.cc index 759e26966e9e7..3607311c1b3ed 100644 --- a/examples/librados/hello_world.cc +++ b/examples/librados/hello_world.cc @@ -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(); } /*