Skip to content

Commit

Permalink
examples/librados: avoid a memory leak
Browse files Browse the repository at this point in the history
Avoid a memory leak by deallocating the pre-allocated aio completion.

Signed-off-by: Injae Kang <[email protected]>
  • Loading branch information
abcinje committed Sep 18, 2021
1 parent ca49104 commit acc929a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/librados/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -164,13 +165,15 @@ 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
<< ", and got back " << ret << " bytes with contents\n";
std::string read_string;
read_buf.begin().copy(ret, read_string);
std::cout << read_string << std::endl;
read_completion->release();
}

/*
Expand Down

0 comments on commit acc929a

Please sign in to comment.