Skip to content

Commit ed87638

Browse files
pablomadoerylevy
authored andcommitted
Fix memory leak in MessageDispatcher when outGate->deliver returns false
1 parent 2b58f34 commit ed87638

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/inet/common/MessageDispatcher.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ void MessageDispatcher::arrived(cMessage *message, cGate *inGate, const SendOpti
110110
}
111111
else
112112
outGate = handleMessage(check_and_cast<Message *>(message), inGate);
113-
outGate->deliver(message, options, time);
113+
bool keepMsg = outGate->deliver(message, options, time);
114+
if (!keepMsg) {
115+
take(message);
116+
delete message;
117+
}
114118
#ifdef INET_WITH_QUEUEING
115119
#endif // #ifdef INET_WITH_QUEUEING
116120
}

0 commit comments

Comments
 (0)