Browse Source

Don't assume vault strings are null-terminated

Adam Johnson 10 years ago
parent
commit
352c9f9427
  1. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

@ -425,11 +425,13 @@ template<>
static void IRead<plString>(const uint8_t*& buf, plString& dest)
{
uint32_t size = *(reinterpret_cast<const uint32_t*>(buf));
uint32_t arraySize = size / 2;
buf += sizeof(uint32_t);
plStringBuffer<uint16_t> str;
uint16_t* theStrBuffer = str.CreateWritableBuffer(size / sizeof(uint16_t));
uint16_t* theStrBuffer = str.CreateWritableBuffer(arraySize - 1);
memcpy(theStrBuffer, buf, size);
theStrBuffer[arraySize - 1] = 0;
dest = plString::FromUtf16(str);
buf += size;
}

Loading…
Cancel
Save