Skip to content

Commit

Permalink
Fixed #9140 (Wrong behavior of fileRead function if bytes request exc…
Browse files Browse the repository at this point in the history
…eed 10000)

Bug introduced in 23f4001 (Fixed crash when using fileRead with a large count argument)
  • Loading branch information
ccw808 committed Feb 8, 2016
1 parent 129af8b commit 99eee19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion MTA10/mods/shared_logic/CScriptFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ long CScriptFile::Read ( unsigned long ulSize, CBuffer& outBuffer )
m_pFile->FSeek ( 0, SEEK_END );
long lFileSize = m_pFile->FTell ();
m_pFile->FSeek ( lCurrentPos, SEEK_SET );
ulSize = Min < unsigned long > ( lFileSize - lCurrentPos, ulSize );
ulSize = Min < unsigned long > ( 1 + lFileSize - lCurrentPos, ulSize );
// Note: Read extra byte at end so EOF indicator gets set
}

outBuffer.SetSize( ulSize );
Expand Down
3 changes: 2 additions & 1 deletion MTA10_Server/mods/deathmatch/logic/CScriptFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ long CScriptFile::Read ( unsigned long ulSize, CBuffer& outBuffer )
fseek ( m_pFile, 0, SEEK_END );
long lFileSize = ftell ( m_pFile );
fseek ( m_pFile, lCurrentPos, SEEK_SET );
ulSize = Min < unsigned long > ( lFileSize - lCurrentPos, ulSize );
ulSize = Min < unsigned long > ( 1 + lFileSize - lCurrentPos, ulSize );
// Note: Read extra byte at end so EOF indicator gets set
}

outBuffer.SetSize( ulSize );
Expand Down

1 comment on commit 99eee19

@mantisbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues mentioned in this commit (99eee19):

Please sign in to comment.