forked from Mirrorlandia_minetest/irrlicht
Fix bounds checking in CMemoryWriteFile::seek
Thanks @sfan5 for patch: a3d848ff8b
Note I also modified the bounds checks for CMemoryReadFile once more to unify it with how Minetest fixed it.
Due to some strange coincidence I had run into that bug yesterday for CMemoryReadFile and fixed it without realizing a fix was also part of a bunch of patches I had gotten 3 days earlier in the forum:
https://irrlicht.sourceforge.io/forum/viewtopic.php?f=2&t=52819&p=306518#p306518
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6352 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
a48b3a8d00
commit
0317f678fb
@ -52,15 +52,14 @@ bool CMemoryReadFile::seek(long finalPos, bool relativeMovement)
|
||||
{
|
||||
if (relativeMovement)
|
||||
{
|
||||
const long newPos = Pos + finalPos;
|
||||
if (newPos > Len || newPos < 0)
|
||||
if (Pos + finalPos < 0 || Pos + finalPos > Len)
|
||||
return false;
|
||||
|
||||
Pos += finalPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (finalPos > Len || finalPos < 0)
|
||||
if (finalPos < 0 || finalPos > Len)
|
||||
return false;
|
||||
|
||||
Pos = finalPos;
|
||||
@ -134,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;
|
||||
|
Loading…
Reference in New Issue
Block a user