mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
Fixed: FString::ReallocBuffer could write to unallocated memory
- Previously, calling ReallocBuffer with a smaller buffer size than the current one could overwrite unallocated memory. This required that the string it was called on had more than one reference and therefore required creating a new copy. The entire original string would be copied, whether it fit in the new buffer or not.
This commit is contained in:
parent
6da887c34f
commit
e451faa1cc
1 changed files with 1 additions and 1 deletions
|
@ -1096,7 +1096,7 @@ void FString::ReallocBuffer (size_t newlen)
|
|||
{ // If more than one reference, we must use a new copy
|
||||
FStringData *old = Data();
|
||||
AllocBuffer (newlen);
|
||||
StrCopy (Chars, old->Chars(), old->Len);
|
||||
StrCopy (Chars, old->Chars(), newlen < old->Len ? newlen : old->Len);
|
||||
old->Release();
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue