aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-05 00:12:08 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-13 17:06:09 +0100
commit097417299a0ef87cb3d459388a4b313272d74c38 (patch)
tree7f661f395ac31bf82caa0d18ab7fa7f3b41fad33 /libswscale/utils.c
parent3a691185f732cbb5b350fbf2327817087b2a3a30 (diff)
downloadffmpeg-097417299a0ef87cb3d459388a4b313272d74c38.tar.gz
swscale/utils: Limit filter shifting so as not to read from prior the array
Fixes out of array read Fixes: asan_heap-oob_1fb2f9b_3780_cov_3984375136_usf.mkv Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 692b22626ec9a9585f667c124a186b1a9796e432) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r--libswscale/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 55ade89fc4..92e712bf42 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -571,14 +571,15 @@ static int initFilter(int16_t **outFilter, int32_t **filterPos,
}
if ((*filterPos)[i] + filterSize > srcW) {
- int shift = (*filterPos)[i] + filterSize - srcW;
+ int shift = (*filterPos)[i] + FFMIN(filterSize - srcW, 0);
+
// move filter coefficients right to compensate for filterPos
for (j = filterSize - 2; j >= 0; j--) {
int right = FFMIN(j + shift, filterSize - 1);
filter[i * filterSize + right] += filter[i * filterSize + j];
filter[i * filterSize + j] = 0;
}
- (*filterPos)[i]= srcW - filterSize;
+ (*filterPos)[i]-= shift;
}
}