Skip to content

Commit

Permalink
CImg<T>::_cubic_at???(): Fix bad memory access when NaN coordinates a…
Browse files Browse the repository at this point in the history
…re provided.
  • Loading branch information
dtschump committed Sep 4, 2018
1 parent 2e5b53b commit 6d404f1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions CImg.h
Original file line number Diff line number Diff line change
Expand Up @@ -13817,7 +13817,7 @@ namespace cimg_library_suffixed {

Tfloat _cubic_atX(const float fx, const int y=0, const int z=0, const int c=0) const {
const float
nfx = cimg::cut(fx,0,width() - 1);
nfx = cimg::type<float>::is_nan(fx)?0:cimg::cut(fx,0,width() - 1);
const int
x = (int)nfx;
const float
Expand Down Expand Up @@ -13896,13 +13896,13 @@ namespace cimg_library_suffixed {

Tfloat _cubic_atXY(const float fx, const float fy, const int z=0, const int c=0) const {
const float
nfx = cimg::cut(fx,0,width() - 1),
nfy = cimg::cut(fy,0,height() - 1);
nfx = cimg::type<float>::is_nan(fx)?0:cimg::cut(fx,0,width() - 1),
nfy = cimg::type<float>::is_nan(fy)?0:cimg::cut(fy,0,height() - 1);
const int x = (int)nfx, y = (int)nfy;
const float dx = nfx - x, dy = nfy - y;
const int
px = x - 1<0?0:x - 1, nx = dx>0?x + 1:x, ax = x + 2>=width()?width() - 1:x + 2,
py = y - 1<0?0:y - 1, ny = dy>0?y + 1:y, ay = y + 2>=height()?height() - 1:y + 2;
px = x - 1<0?0:x - 1, nx = dx<=0?x:x + 1, ax = x + 2>=width()?width() - 1:x + 2,
py = y - 1<0?0:y - 1, ny = dy<=0?y:y + 1, ay = y + 2>=height()?height() - 1:y + 2;
const Tfloat
Ipp = (Tfloat)(*this)(px,py,z,c), Icp = (Tfloat)(*this)(x,py,z,c), Inp = (Tfloat)(*this)(nx,py,z,c),
Iap = (Tfloat)(*this)(ax,py,z,c),
Expand Down Expand Up @@ -14046,9 +14046,9 @@ namespace cimg_library_suffixed {

Tfloat _cubic_atXYZ(const float fx, const float fy, const float fz, const int c=0) const {
const float
nfx = cimg::cut(fx,0,width() - 1),
nfy = cimg::cut(fy,0,height() - 1),
nfz = cimg::cut(fz,0,depth() - 1);
nfx = cimg::type<float>::is_nan(fx)?0:cimg::cut(fx,0,width() - 1),
nfy = cimg::type<float>::is_nan(fy)?0:cimg::cut(fy,0,height() - 1),
nfz = cimg::type<float>::is_nan(fz)?0:cimg::cut(fz,0,depth() - 1);
const int x = (int)nfx, y = (int)nfy, z = (int)nfz;
const float dx = nfx - x, dy = nfy - y, dz = nfz - z;
const int
Expand Down

0 comments on commit 6d404f1

Please sign in to comment.