Skip to content

Commit

Permalink
Fix undefined behaviour on getting pointer to data in empty vector
Browse files Browse the repository at this point in the history
`&vector[0]` is undefined if vector.empty(), causing build failure on MSVC
  • Loading branch information
nOOb3167 authored and rubenwardy committed Dec 22, 2017
1 parent 257626c commit 7354d0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/network/networkpacket.cpp
Expand Up @@ -63,7 +63,7 @@ void NetworkPacket::putRawPacket(u8 *data, u32 datasize, session_t 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)
Expand Down

0 comments on commit 7354d0f

Please sign in to comment.