mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
fix use after free of pending message
This commit is contained in:
parent
b6d8434b55
commit
31e9f26772
1 changed files with 7 additions and 1 deletions
|
@ -191,6 +191,8 @@ void Connection::queueReceivedMessagePacket(std::unique_ptr<Packet> packet) {
|
|||
|
||||
pendingMessage.enqueuePacket(std::move(packet));
|
||||
|
||||
bool processedLastOrOnly = false;
|
||||
|
||||
while (pendingMessage.hasAvailablePackets()) {
|
||||
auto packet = pendingMessage.removeNextPacket();
|
||||
|
||||
|
@ -201,9 +203,13 @@ void Connection::queueReceivedMessagePacket(std::unique_ptr<Packet> packet) {
|
|||
// if this was the last or only packet, then we can remove the pending message from our hash
|
||||
if (packetPosition == Packet::PacketPosition::LAST ||
|
||||
packetPosition == Packet::PacketPosition::ONLY) {
|
||||
_pendingReceivedMessages.erase(messageNumber);
|
||||
processedLastOrOnly = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (processedLastOrOnly) {
|
||||
_pendingReceivedMessages.erase(messageNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void Connection::sync() {
|
||||
|
|
Loading…
Reference in a new issue