From 8f9a44514f86b73a8f02e934d907b30c6e56f4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 21 Jun 2023 20:50:28 +0200 Subject: [PATCH] Remove unnecessary `RangeCheck` function --- src/engine/shared/snapshot.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/engine/shared/snapshot.cpp b/src/engine/shared/snapshot.cpp index 762a67c08..ad704d923 100644 --- a/src/engine/shared/snapshot.cpp +++ b/src/engine/shared/snapshot.cpp @@ -352,13 +352,6 @@ int CSnapshotDelta::CreateDelta(const CSnapshot *pFrom, CSnapshot *pTo, void *pD return (int)((char *)pData - (char *)pDstData); } -static int RangeCheck(void *pEnd, void *pPtr, int Size) -{ - if((const char *)pPtr + Size > (const char *)pEnd) - return -1; - return 0; -} - int CSnapshotDelta::UnpackDelta(const CSnapshot *pFrom, CSnapshot *pTo, const void *pSrcData, int DataSize) { CData *pDelta = (CData *)pSrcData; @@ -428,7 +421,7 @@ int CSnapshotDelta::UnpackDelta(const CSnapshot *pFrom, CSnapshot *pTo, const vo ItemSize = (*pData++) * sizeof(int32_t); } - if(ItemSize < 0 || RangeCheck(pEnd, pData, ItemSize)) + if(ItemSize < 0 || (const char *)pEnd - (const char *)pData < ItemSize) return -205; const int Key = (Type << 16) | ID;