From: Loïc Blot Date: Mon, 28 Aug 2017 15:12:30 +0000 (+0200) Subject: Pass SharedBuffer as value to increment reference count X-Git-Tag: 5.0.0~879 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6fd8a27c91b09f51693243586af3615f962d1730;p=oweals%2Fminetest.git Pass SharedBuffer as value to increment reference count This should fix #6332 Refcount is not increased due to reference, it can make this refcount incorrect in a multithread context --- diff --git a/src/network/connectionthreads.cpp b/src/network/connectionthreads.cpp index b07acd469..63c1855c5 100644 --- a/src/network/connectionthreads.cpp +++ b/src/network/connectionthreads.cpp @@ -1098,7 +1098,7 @@ bool ConnectionReceiveThread::checkIncomingBuffers(Channel *channel, } SharedBuffer ConnectionReceiveThread::processPacket(Channel *channel, - SharedBuffer &packetdata, u16 peer_id, u8 channelnum, bool reliable) + SharedBuffer packetdata, u16 peer_id, u8 channelnum, bool reliable) { PeerHelper peer = m_connection->getPeerNoEx(peer_id); @@ -1137,7 +1137,7 @@ const ConnectionReceiveThread::PacketTypeHandler }; SharedBuffer ConnectionReceiveThread::handlePacketType_Control(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, bool reliable) + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable) { if (packetdata.getSize() < 2) throw InvalidIncomingDataException("packetdata.getSize() < 2"); @@ -1247,7 +1247,7 @@ SharedBuffer ConnectionReceiveThread::handlePacketType_Control(Channel *chan } SharedBuffer ConnectionReceiveThread::handlePacketType_Original(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, bool reliable) + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable) { if (packetdata.getSize() <= ORIGINAL_HEADER_SIZE) throw InvalidIncomingDataException @@ -1261,7 +1261,7 @@ SharedBuffer ConnectionReceiveThread::handlePacketType_Original(Channel *cha } SharedBuffer ConnectionReceiveThread::handlePacketType_Split(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, bool reliable) + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable) { Address peer_address; @@ -1292,7 +1292,7 @@ SharedBuffer ConnectionReceiveThread::handlePacketType_Split(Channel *channe } SharedBuffer ConnectionReceiveThread::handlePacketType_Reliable(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, bool reliable) + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable) { assert(channel != NULL); diff --git a/src/network/connectionthreads.h b/src/network/connectionthreads.h index 11bec0c6c..c2314f87f 100644 --- a/src/network/connectionthreads.h +++ b/src/network/connectionthreads.h @@ -118,26 +118,26 @@ private: channelnum: channel on which the packet was sent reliable: true if recursing into a reliable packet */ - SharedBuffer processPacket(Channel *channel, SharedBuffer &packetdata, + SharedBuffer processPacket(Channel *channel, SharedBuffer packetdata, u16 peer_id, u8 channelnum, bool reliable); SharedBuffer handlePacketType_Control(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable); SharedBuffer handlePacketType_Original(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable); SharedBuffer handlePacketType_Split(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable); SharedBuffer handlePacketType_Reliable(Channel *channel, - SharedBuffer &packetdata, Peer *peer, u8 channelnum, + SharedBuffer packetdata, Peer *peer, u8 channelnum, bool reliable); struct PacketTypeHandler { SharedBuffer (ConnectionReceiveThread::*handler)(Channel *channel, - SharedBuffer &packet, Peer *peer, u8 channelnum, + SharedBuffer packet, Peer *peer, u8 channelnum, bool reliable); };