Skip to content

Commit

Permalink
Fix SetStreamingBufferSizepossibly accessing memory out-of-bounds (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pirulax committed Jan 5, 2024
1 parent 478fd54 commit e08b84f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Client/game_sa/CStreamingSA.cpp
Expand Up @@ -431,6 +431,8 @@ void CStreamingSA::RemoveArchive(unsigned char ucArchiveID)

bool CStreamingSA::SetStreamingBufferSize(uint32 numBlocks)
{
numBlocks += numBlocks % 2; // Make sure number is even by "rounding" it upwards. [Otherwise it can't be split in half properly]

// Check if the size is the same already
if (numBlocks == ms_streamingHalfOfBufferSizeBlocks * 2)
return true;
Expand All @@ -453,10 +455,6 @@ bool CStreamingSA::SetStreamingBufferSize(uint32 numBlocks)

// Suspend streaming thread [otherwise data might become corrupted]
SuspendThread(*phStreamingThread);

// Create new buffer
if (numBlocks & 1) // Make it be even [Otherwise it can't be split in half properly]
numBlocks++;

// Calculate new buffer pointers
void* const pNewBuff0 = pNewBuffer;
Expand Down

0 comments on commit e08b84f

Please sign in to comment.