Skip to content

Commit

Permalink
Fix allocation issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-le-cam committed Sep 17, 2024
1 parent 609eef3 commit 8028979
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/s3plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ int driver_disconnect()
active_writer_handles.clear();
active_reader_handles.clear();

client.reset();

ShutdownAPI(options);

bIsConnected = kFalse;
Expand Down Expand Up @@ -1514,7 +1516,7 @@ long long int driver_fwrite(const void* ptr, size_t size, size_t count, void* st
// copy up to capacity for now
size_t remain = to_write;
size_t copy_count = buffer.capacity() - buffer.size();
const unsigned char* ptr_cast_pos = static_cast<const unsigned char*>(ptr);
const unsigned char* ptr_cast_pos = reinterpret_cast<const unsigned char*>(ptr);

auto copy_and_update =
[](Aws::Vector<unsigned char>& dest, const unsigned char** src_start, size_t& count, size_t& remain)
Expand Down
12 changes: 6 additions & 6 deletions test/basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ class S3DriverTestFixture : public ::testing::Test {

public:
// Note: a bit of "rodeo" here: the driver state contains a
// unique_ptr<S3Client> that will be set by the test SetUp and unset by the
// test TearDown. We can't just pass a pointer owned by a shared_ptr, there
// would be conflicts when freeing the associated memory. So, for each test,
// the fixture passes a raw pointer to the driver state for it to own. All is
// well as long as gtest runs the tests sequentially, otherwise the whole
// thing blows up.
// Aws::UniquePtr<S3Client> that will be set by the test SetUp and
// unset by the test TearDown. We can't just pass a pointer owned by a
// shared_ptr, there would be conflicts when freeing the associated memory.
// So, for each test, the fixture passes a raw pointer to the driver state for
// it to own. All is well as long as gtest runs the tests sequentially,
// otherwise the whole thing blows up.
MockS3Client *mock_client_ = nullptr; // avoid repeated casts by casting once
// in setup. not owning, do not free!

Expand Down

0 comments on commit 8028979

Please sign in to comment.