From 9504b3da21698180bad9b9248f090c0ba8e1234e Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 20 Apr 2022 21:57:25 +0000 Subject: [PATCH] Prevent CMemoryFile to seek to a point before the start. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6348 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CMemoryFile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/Irrlicht/CMemoryFile.cpp b/source/Irrlicht/CMemoryFile.cpp index 22c57e65..57064390 100644 --- a/source/Irrlicht/CMemoryFile.cpp +++ b/source/Irrlicht/CMemoryFile.cpp @@ -52,14 +52,15 @@ bool CMemoryReadFile::seek(long finalPos, bool relativeMovement) { if (relativeMovement) { - if (Pos + finalPos > Len) + const long newPos = Pos + finalPos; + if (newPos > Len || newPos < 0) return false; Pos += finalPos; } else { - if (finalPos > Len) + if (finalPos > Len || finalPos < 0) return false; Pos = finalPos;