- fixed: ZScript's lump reader may not truncate strings at 0 bytes, like all other callers of GetStringFromLump need.

This commit is contained in:
Christoph Oelckers 2023-09-16 07:44:21 +02:00
commit 71cc93f42c
3 changed files with 4 additions and 4 deletions

View file

@ -1016,10 +1016,10 @@ void uppercopy(char* to, const char* from)
// Loads a zero terminated string from a lump in the file system
//==========================================================================
FString GetStringFromLump(int lump)
FString GetStringFromLump(int lump, bool zerotruncate)
{
auto fd = fileSystem.ReadFile(lump);
FString ScriptBuffer(fd.GetString(), fd.GetSize());
ScriptBuffer.Truncate(strlen(ScriptBuffer.GetChars())); // this is necessary to properly truncate the generated string to not contain 0 bytes.
if (zerotruncate) ScriptBuffer.Truncate(strlen(ScriptBuffer.GetChars())); // this is necessary to properly truncate the generated string to not contain 0 bytes.
return ScriptBuffer;
}