Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix heap buffer overflow caused by rounding.
This was hard to fix. Due to the way we compute the pixels that influence an output pixel in resized images, for certain input configuration we might have issued a read to a pixel that is outside of boundary of the original image. This is because of floating errors that affected truncation results.

PiperOrigin-RevId: 369757871
Change-Id: If89425fff930983829a2168203c11858883eebc9
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Apr 21, 2021
1 parent 44b7f48 commit f851613
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tensorflow/core/kernels/quantized_resize_bilinear_op.cc
Expand Up @@ -64,6 +64,8 @@ inline void ComputeInterpolationWeights(
std::max(static_cast<int64>(in_f), static_cast<int64>(0));
interpolation->upper[i] =
std::min(static_cast<int64>(std::ceil(in)), in_size - 1);
interpolation->lower[i] =
std::min(interpolation->lower[i], interpolation->upper[i]);
interpolation->lerp[i] = in - in_f;
interpolation->ilerp[i] =
static_cast<T_SCALE>((in - in_f) * (1 << resolution));
Expand Down

0 comments on commit f851613

Please sign in to comment.