From 3adda272b7ac3572b38f71363150a2985365f59d Mon Sep 17 00:00:00 2001 From: Steven Chamberlain Date: Tue, 5 Apr 2016 03:09:51 +0100 Subject: [PATCH] Fix pointer truncation on 64-bit Use size_t instead of int for arithmetic on pointers, to avoid truncation on ILP64 architectures (like amd64). --- Sources/Engine/Sound/SoundObject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Engine/Sound/SoundObject.cpp b/Sources/Engine/Sound/SoundObject.cpp index c53036e..30f150f 100644 --- a/Sources/Engine/Sound/SoundObject.cpp +++ b/Sources/Engine/Sound/SoundObject.cpp @@ -147,7 +147,7 @@ void CSoundObject::Set3DParameters( FLOAT fFalloff, FLOAT fHotSpot, //CPrintF("SET3D: "); CEntity *pen = so_penEntity->GetPredictionTail(); if (pen!=so_penEntity) { - pso = (CSoundObject *)( ((UBYTE*)pen) + (int(this)-int(so_penEntity)) ); + pso = (CSoundObject *)( ((UBYTE*)pen) + (size_t(this)-size_t(so_penEntity)) ); } } } @@ -175,7 +175,7 @@ CSoundObject *CSoundObject::GetPredictionTail(ULONG ulTypeID, ULONG ulEventID) // it must not play the sound return NULL; } - SLONG slOffset = int(this)-int(so_penEntity); + SLONG slOffset = size_t(this)-size_t(so_penEntity); ULONG ulCRC; CRC_Start(ulCRC);