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:
Michael Niedermayer
2026-02-25 00:44:41 +01:00
parent 8cae96eb62
commit 2446135b92
+8 -6
View File
@@ -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;