Skip to content

Commit

Permalink
Fix leaking of consumed buffers for SIO
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Oct 10, 2024
1 parent a2fe073 commit 4622d0b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions include/podio/SIOBlockUserData.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ class SIOBlockUserData : public podio::SIOBlock {
.createBuffers(podio::userDataCollTypeName<BasicType>(), sio::version::major_version(version), false)
.value();

auto* dataVec = new std::vector<BasicType>();
auto* dataVec = m_buffers.dataAsVector<BasicType>();
unsigned size(0);
device.data(size);
dataVec->resize(size);
podio::handlePODDataSIO(device, &(*dataVec)[0], size);
m_buffers.data = dataVec;
}

void write(sio::write_device& device) override {
Expand Down
2 changes: 1 addition & 1 deletion include/podio/SIOFrameData.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SIOFrameData {

public:
SIOFrameData() = delete;
~SIOFrameData() = default;
~SIOFrameData();

SIOFrameData(const SIOFrameData&) = delete;
SIOFrameData& operator=(const SIOFrameData&) = delete;
Expand Down
9 changes: 9 additions & 0 deletions src/SIOFrameData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,13 @@ void SIOFrameData::readIdTable() {
m_subsetCollectionBits = idTableBlock->getSubsetCollectionBits();
}

SIOFrameData::~SIOFrameData() {
for (size_t i = 1; i < m_blocks.size(); ++i) {
if (m_availableBlocks[i]) {
auto buffers = dynamic_cast<SIOBlock*>(m_blocks[i].get())->getBuffers();
buffers.deleteBuffers(buffers);
}
}
}

} // namespace podio
2 changes: 0 additions & 2 deletions tests/CTestCustom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ if ((NOT "@FORCE_RUN_ALL_TESTS@" STREQUAL "ON") AND (NOT "@USE_SANITIZER@" STREQ
read_and_write_sio
write_timed_sio
read_timed_sio
read_frame_sio
read_interface_sio
read_frame_legacy_sio
read_and_write_frame_sio
)
Expand Down

0 comments on commit 4622d0b

Please sign in to comment.