patch to prevent integer overflow

This commit is contained in:
Sébastien Loriot 2011-12-29 08:14:37 +00:00
parent 6218ff55d6
commit 894b8c36d5
1 changed files with 4 additions and 3 deletions

View File

@ -1509,6 +1509,10 @@ float triLinInterp(const _image* image,
posy = static_cast<float>(posy /(image->vy));
posz = static_cast<float>(posz /(image->vz));
//patch suggested by J.Cugnoni to prevent integer overflow
if(posz >= dimz-1 || posy >= dimy-1 || posx >= dimx-1)
return value_outside;
const int i1 = (int)(posz);
const int j1 = (int)(posy);
const int k1 = (int)(posx);
@ -1517,9 +1521,6 @@ float triLinInterp(const _image* image,
const int j2 = j1 + 1;
const int k2 = k1 + 1;
if(i2 >= dimz || j2 >= dimy || k2 >= dimx)
return value_outside;
const float KI2 = i2-posz;
const float KI1 = posz-i1;
const float KJ2 = j2-posy;