aboutsummaryrefslogtreecommitdiff
path: root/source/scale.cc
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc@google.com>2023-04-05 14:43:19 -0700
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-05 21:58:22 +0000
commitec48e4328eac1f137dc6eff8d6f1dd38810fe583 (patch)
tree5ca72a11d33f89913cd2075e42dddcc141225298 /source/scale.cc
parent464c51a0353c71f08fe45f683d6a97a638d47833 (diff)
downloadlibyuv-ec48e4328eac1f137dc6eff8d6f1dd38810fe583.tar.gz
Add assertions for the Clang static analyzer
The Clang static analyzer (scan-build) in LLVM 14 warns about array index out of bounds in scaletbl[boxwidth - minboxwidth] in ScaleAddCols2_C() and ScaleAddCols2_16_C(). The scaletbl array has two elements. It's not clear the index boxwidth - minboxwidth is either 0 or 1. Change-Id: I072476e86950154beffe6b1a89915755118b3cbd Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4403882 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Wan-Teh Chang <wtc@google.com>
Diffstat (limited to 'source/scale.cc')
-rw-r--r--source/scale.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/source/scale.cc b/source/scale.cc
index 830754ce..90abaefe 100644
--- a/source/scale.cc
+++ b/source/scale.cc
@@ -820,6 +820,7 @@ static void ScaleAddCols2_C(int dst_width,
int ix = x >> 16;
x += dx;
boxwidth = MIN1((x >> 16) - ix);
+ assert(((boxwidth - minboxwidth) == 0) || ((boxwidth - minboxwidth) == 1));
*dst_ptr++ = (uint8_t)(SumPixels(boxwidth, src_ptr + ix) *
scaletbl[boxwidth - minboxwidth] >>
16);
@@ -842,6 +843,7 @@ static void ScaleAddCols2_16_C(int dst_width,
int ix = x >> 16;
x += dx;
boxwidth = MIN1((x >> 16) - ix);
+ assert(((boxwidth - minboxwidth) == 0) || ((boxwidth - minboxwidth) == 1));
*dst_ptr++ = SumPixels_16(boxwidth, src_ptr + ix) *
scaletbl[boxwidth - minboxwidth] >>
16;