Skip to content

Commit 57e4b62

Browse files
committed
getLastPointerFromPath - Make sure the address + the offset is valid before loading from it
1 parent e02c74b commit 57e4b62

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ttyd-tools/rel/source/commonfunctions.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,10 @@ void *getLastPointerFromPath(void *address, int32_t *offset, uint32_t offsetAmou
317317
uint32_t Counter = 0;
318318
for (uint32_t i = 0; i < (offsetAmount - 1); i++)
319319
{
320-
if (checkIfPointerIsValid(reinterpret_cast<void *>(tempAddress)))
320+
uint32_t *tempAddress2 = reinterpret_cast<uint32_t *>(tempAddress + offset[i]);
321+
if (checkIfPointerIsValid(tempAddress2))
321322
{
322-
tempAddress = *reinterpret_cast<uint32_t *>(tempAddress + offset[i]);
323+
tempAddress = *tempAddress2;
323324
}
324325
else
325326
{

0 commit comments

Comments
 (0)