Skip to content

Commit

Permalink
CMemoryFile: fix seek bounds-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Mar 12, 2021
1 parent 57ff34b commit a3d848f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/Irrlicht/CMemoryFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ bool CMemoryReadFile::seek(long finalPos, bool relativeMovement)
{
if (relativeMovement)
{
if (Pos + finalPos > Len)
if (Pos + finalPos < 0 || Pos + finalPos > Len)
return false;

Pos += finalPos;
}
else
{
if (finalPos > Len)
if (finalPos < 0 || finalPos > Len)
return false;

Pos = finalPos;
Expand Down Expand Up @@ -133,14 +133,14 @@ bool CMemoryWriteFile::seek(long finalPos, bool relativeMovement)
{
if (relativeMovement)
{
if (Pos + finalPos > Len)
if (Pos + finalPos < 0 || Pos + finalPos > Len)
return false;

Pos += finalPos;
}
else
{
if (finalPos > Len)
if (finalPos < 0 || finalPos > Len)
return false;

Pos = finalPos;
Expand Down

0 comments on commit a3d848f

Please sign in to comment.