mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +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
|
{ // If more than one reference, we must use a new copy
|
||||||
FStringData *old = Data();
|
FStringData *old = Data();
|
||||||
AllocBuffer (newlen);
|
AllocBuffer (newlen);
|
||||||
StrCopy (Chars, old->Chars(), old->Len);
|
StrCopy (Chars, old->Chars(), newlen < old->Len ? newlen : old->Len);
|
||||||
old->Release();
|
old->Release();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue