From a3c298e1d1f02634e87c7ba1746fd7e9ed444875 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Tue, 5 Sep 2017 22:14:56 +0200 Subject: [PATCH] Use a Buffer instead of SharedBuffer in ConnectionCommand This fixes #6373 --- src/network/connection.h | 2 +- src/util/pointer.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/network/connection.h b/src/network/connection.h index d569722bf..5062b73d0 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -325,7 +325,7 @@ struct ConnectionCommand Address address; u16 peer_id = PEER_ID_INEXISTENT; u8 channelnum = 0; - SharedBuffer data; + Buffer data; bool reliable = false; bool raw = false; diff --git a/src/util/pointer.h b/src/util/pointer.h index efca62d2d..59b6f5216 100644 --- a/src/util/pointer.h +++ b/src/util/pointer.h @@ -168,6 +168,18 @@ public: /* Copies whole buffer */ + SharedBuffer(const Buffer &buffer) + { + m_size = buffer.getSize(); + if (m_size != 0) { + data = new T[m_size]; + memcpy(data, *buffer, buffer.getSize()); + } + else + data = NULL; + refcount = new unsigned int; + (*refcount) = 1; + } ~SharedBuffer() { drop(); -- 2.25.1