Skip to content

Conversation

@celskeggs
Copy link
Collaborator

@celskeggs celskeggs commented May 13, 2025

Related Issue(s) n/a
Has Unit Tests (y/n) n
Documentation Included (y/n) n

Change Description

drvReceiveIn passes ownership of recvBuffer, but ComStub only took care of deallocating the buffer if the read operation succeeded. If a communications driver indicates that a read did not succeed (for example with status RECV_NO_DATA), the buffer is lost and memory is leaked.

Rationale

Memory leaks cause FSW to fail to operate correctly.

Testing/Review Recommendations

This should probably be unit tested to prevent regressions, but that's not covered in this PR.

Future Work

It would be worth thinking about how we could avoid these sorts of buffer handling problems in the future.

drvReceiveIn passes ownership of recvBuffer, but ComStub only took care
of deallocating the buffer if the read operation succeeded.
ComCfg::FrameContext emptyContext; // ComStub knows nothing about the received bytes, so use an empty context
this->dataOut_out(0, recvBuffer, emptyContext);
} else {
this->drvReceiveReturnOut_out(0, recvBuffer);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter recvBuffer has not been checked.
@LeStarch LeStarch requested a review from thomas-bc May 14, 2025 15:32
@LeStarch
Copy link
Collaborator

@thomas-bc this looks right to me, but I'd prefer you to review.

Copy link
Collaborator

@thomas-bc thomas-bc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! 👀
Good catch, thank you!

@thomas-bc thomas-bc merged commit a7d9db1 into nasa:devel May 14, 2025
44 checks passed
@celskeggs celskeggs deleted the patch-15 branch May 14, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants