mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-18 15:42:34 +00:00
Fixed: TicSpecial could run out of space when writing data
- Fixed: TicSpecial::CheckSpace() never thought it ran out of space due to unsigned math. - Fixed: TicSpecial::GetMoreSpace() assumed only relatively small amounts of data would be written at a time so made no effort to ensure it actually got enough space. This assumption could be violated by writing a very long string, which can happen when replicating a string cvar.
This commit is contained in:
parent
26cf383ead
commit
86986446a5
1 changed files with 5 additions and 5 deletions
|
@ -185,7 +185,7 @@ static struct TicSpecial
|
|||
size_t used[BACKUPTICS];
|
||||
BYTE *streamptr;
|
||||
size_t streamoffs;
|
||||
int specialsize;
|
||||
size_t specialsize;
|
||||
int lastmaketic;
|
||||
bool okay;
|
||||
|
||||
|
@ -224,11 +224,11 @@ static struct TicSpecial
|
|||
}
|
||||
|
||||
// Make more room for special commands.
|
||||
void GetMoreSpace ()
|
||||
void GetMoreSpace (size_t needed)
|
||||
{
|
||||
int i;
|
||||
|
||||
specialsize <<= 1;
|
||||
specialsize = MAX(specialsize * 2, needed + 30);
|
||||
|
||||
DPrintf ("Expanding special size to %d\n", specialsize);
|
||||
|
||||
|
@ -240,8 +240,8 @@ static struct TicSpecial
|
|||
|
||||
void CheckSpace (size_t needed)
|
||||
{
|
||||
if (streamoffs >= specialsize - needed)
|
||||
GetMoreSpace ();
|
||||
if (streamoffs + needed >= specialsize)
|
||||
GetMoreSpace (streamoffs + needed);
|
||||
|
||||
streamoffs += needed;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue