CMemoryFile: fix seek bounds-checking

This commit is contained in:
sfan5 2021-03-12 18:28:10 +01:00
parent 57ff34b1ed
commit a3d848ff8b

View File

@ -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;
@ -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;