avfilter/vf_convolution: Handle corner cases with small frames
Fixes: out of array read
Fixes: #YWH-PGM40646-35
Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e24b9820b4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -628,10 +628,12 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
continue;
|
||||
}
|
||||
for (y = slice_start; y < slice_end; y += step) {
|
||||
const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : radius * bpc;
|
||||
const int yoff = mode == MATRIX_COLUMN ? radius * dstride : 0;
|
||||
const int left = FFMIN(radius, sizew);
|
||||
const int right = FFMAX(left, sizew - radius);
|
||||
const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : left * bpc;
|
||||
const int yoff = mode == MATRIX_COLUMN ? left * dstride : 0;
|
||||
|
||||
for (x = 0; x < radius; x++) {
|
||||
for (x = 0; x < left; x++) {
|
||||
const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : x * bpc;
|
||||
const int yoff = mode == MATRIX_COLUMN ? x * dstride : 0;
|
||||
|
||||
@@ -640,11 +642,11 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
bias, matrix, c, s->max, radius,
|
||||
dstride, stride, slice_end - step);
|
||||
}
|
||||
s->setup[plane](radius, c, src, stride, radius, width, y, height, bpc);
|
||||
s->filter[plane](dst + yoff + xoff, sizew - 2 * radius,
|
||||
s->setup[plane](radius, c, src, stride, left, width, y, height, bpc);
|
||||
s->filter[plane](dst + yoff + xoff, right - left,
|
||||
rdiv, bias, matrix, c, s->max, radius,
|
||||
dstride, stride, slice_end - step);
|
||||
for (x = sizew - radius; x < sizew; x++) {
|
||||
for (x = right; x < sizew; x++) {
|
||||
const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : x * bpc;
|
||||
const int yoff = mode == MATRIX_COLUMN ? x * dstride : 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user