Skip to content

Commit df7186f

Browse files
author
Seçkin Sefa Durası
committed
Construct the tester DP buffer instead of setting its data
Fw::Buffer::setData now advances within an existing allocation and asserts on a null backing pointer, so it can no longer initialize a default-constructed buffer. The tester used setData plus setSize to set up the container buffer, which aborted in Fw/Buffer/Buffer.cpp once the branch was rebased onto current devel. Build the buffer with the Fw::Buffer constructor in both resetDpState and productGet_handler, keeping the undersized-buffer path used by the serialization-failure test.
1 parent 62c2eb5 commit df7186f

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎Svc/FileManager/test/ut/FileManagerTester.cpp‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,20 @@ void FileManagerTester ::resetDpState() {
361361
this->m_dpGetShouldFail = false;
362362
this->m_dpGetUndersizedBuffer = false;
363363
this->m_dpLastPriority = 0;
364-
this->m_dpContainerBuffer.setData(this->m_dpContainerData);
365-
this->m_dpContainerBuffer.setSize(sizeof this->m_dpContainerData);
364+
// Construct the buffer over the backing store: setData adjusts an existing
365+
// allocation rather than establishing one, so it cannot initialize a
366+
// default-constructed buffer
367+
this->m_dpContainerBuffer = Fw::Buffer(this->m_dpContainerData, sizeof this->m_dpContainerData);
366368
}
367369

368370
Fw::Success::T FileManagerTester ::productGet_handler(FwDpIdType id, FwSizeType size, Fw::Buffer& buffer) {
369371
if (this->m_dpGetShouldFail || (size > sizeof this->m_dpContainerData)) {
370372
return Fw::Success::FAILURE;
371373
}
372-
this->m_dpContainerBuffer.setData(this->m_dpContainerData);
373374
// An undersized buffer lets the serialization failure path be exercised
374-
this->m_dpContainerBuffer.setSize(this->m_dpGetUndersizedBuffer ? Fw::DpContainer::MIN_PACKET_SIZE
375-
: sizeof this->m_dpContainerData);
375+
const FwSizeType bufferSize =
376+
this->m_dpGetUndersizedBuffer ? Fw::DpContainer::MIN_PACKET_SIZE : sizeof this->m_dpContainerData;
377+
this->m_dpContainerBuffer = Fw::Buffer(this->m_dpContainerData, bufferSize);
376378
buffer = this->m_dpContainerBuffer;
377379
return Fw::Success::SUCCESS;
378380
}

0 commit comments

Comments
 (0)