mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-16 17:21:10 +00:00
- fixed: ZScript's lump reader may not truncate strings at 0 bytes, like all other callers of GetStringFromLump need.
This commit is contained in:
parent
45a2cbe081
commit
71cc93f42c
3 changed files with 4 additions and 4 deletions
|
@ -844,7 +844,7 @@ DEFINE_ACTION_FUNCTION(_Wads, ReadLump)
|
|||
PARAM_PROLOGUE;
|
||||
PARAM_INT(lump);
|
||||
const bool isLumpValid = lump >= 0 && lump < fileSystem.GetNumEntries();
|
||||
ACTION_RETURN_STRING(isLumpValid ? GetStringFromLump(lump) : FString());
|
||||
ACTION_RETURN_STRING(isLumpValid ? GetStringFromLump(lump, false) : FString());
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ struct MD5Context;
|
|||
|
||||
void md5Update(FileReader& file, MD5Context& md5, unsigned len);
|
||||
void uppercopy(char* to, const char* from);
|
||||
FString GetStringFromLump(int lump);
|
||||
FString GetStringFromLump(int lump, bool zerotruncate = true);
|
||||
|
||||
inline void fillshort(void* buff, size_t count, uint16_t clear)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue