Skip to content

Commit

Permalink
Stop ignoring real buffers shrunk to 0 size
Browse files Browse the repository at this point in the history
Without this fix, trying to return allocated buffers to a BufferManager
with sizes updated to 0 can result in a memory leak.
  • Loading branch information
celskeggs committed Jan 23, 2025
1 parent b4cfcaf commit 00c5016
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Svc/BufferManager/BufferManagerComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ namespace Svc {
// make sure component has been set up
FW_ASSERT(this->m_setup);
FW_ASSERT(m_buffers);
// check for empty buffers - this is just a warning since this component returns
// empty buffers if it can't allocate one.
if (fwBuffer.getSize() == 0) {
// check for null, empty buffers - this is a warning because this component returns
// null, empty buffers if it can't allocate one.
// however, empty non-null buffers could potentially be previously allocated
// buffers with their size reduced. the user is allowed to make buffers smaller.
if (fwBuffer.getData() == nullptr && fwBuffer.getSize() == 0) {
this->log_WARNING_HI_ZeroSizeBuffer();
this->m_emptyBuffs++;
return;
Expand Down

0 comments on commit 00c5016

Please sign in to comment.