From: nOOb3167 Date: Fri, 22 Dec 2017 10:33:46 +0000 (+0100) Subject: Fix undefined behaviour on getting pointer to data in empty vector X-Git-Tag: 0.4.17~42 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bb219e1059b711ba9663ed42304c8c22cacf86ab;p=oweals%2Fminetest.git Fix undefined behaviour on getting pointer to data in empty vector `&vector[0]` is undefined if vector.empty(), causing build failure on MSVC --- diff --git a/src/network/networkpacket.cpp b/src/network/networkpacket.cpp index 8e06ae104..c4fcf9600 100644 --- a/src/network/networkpacket.cpp +++ b/src/network/networkpacket.cpp @@ -62,7 +62,7 @@ void NetworkPacket::putRawPacket(u8 *data, u32 datasize, u16 peer_id) // split command and datas m_command = readU16(&data[0]); - memcpy(&m_data[0], &data[2], m_datasize); + memcpy(m_data.data(), &data[2], m_datasize); } const char* NetworkPacket::getString(u32 from_offset)