mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Don't assume vault strings are null-terminated
This commit is contained in:
@ -425,11 +425,13 @@ template<>
|
|||||||
static void IRead<plString>(const uint8_t*& buf, plString& dest)
|
static void IRead<plString>(const uint8_t*& buf, plString& dest)
|
||||||
{
|
{
|
||||||
uint32_t size = *(reinterpret_cast<const uint32_t*>(buf));
|
uint32_t size = *(reinterpret_cast<const uint32_t*>(buf));
|
||||||
|
uint32_t arraySize = size / 2;
|
||||||
buf += sizeof(uint32_t);
|
buf += sizeof(uint32_t);
|
||||||
|
|
||||||
plStringBuffer<uint16_t> str;
|
plStringBuffer<uint16_t> str;
|
||||||
uint16_t* theStrBuffer = str.CreateWritableBuffer(size / sizeof(uint16_t));
|
uint16_t* theStrBuffer = str.CreateWritableBuffer(arraySize - 1);
|
||||||
memcpy(theStrBuffer, buf, size);
|
memcpy(theStrBuffer, buf, size);
|
||||||
|
theStrBuffer[arraySize - 1] = 0;
|
||||||
dest = plString::FromUtf16(str);
|
dest = plString::FromUtf16(str);
|
||||||
buf += size;
|
buf += size;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user