Skip to content

Comments

Fix memory leak in MessageDispatcher when outGate->deliver returns false#1094

Closed
pablomadoery wants to merge 1 commit intoinet-framework:masterfrom
pablomadoery:fix-message-dispatcher-leak-minimal
Closed

Fix memory leak in MessageDispatcher when outGate->deliver returns false#1094
pablomadoery wants to merge 1 commit intoinet-framework:masterfrom
pablomadoery:fix-message-dispatcher-leak-minimal

Conversation

@pablomadoery
Copy link
Contributor

This PR fixes a packet memory leak in inet/common/MessageDispatcher.cc.

If outGate->deliver(...) returns false (meaning the message could not be delivered natively by the channel), the current code effectively discards the pointer without deleting it, resulting in a memory leak.

This PR adds a keepMsg check to capture the return value of deliver(), and strictly deletes the message if it was not taken by the gate, matching OMNeT++ ownership semantics.

Note: This supersedes PR #1091 with a clean functional-only patch that strictly preserves the original file formatting.

@pablomadoery pablomadoery deleted the fix-message-dispatcher-leak-minimal branch February 23, 2026 15:22
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.

1 participant