aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-10-15 16:38:40 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2022-05-04 19:25:41 +0200
commita19796a15ee0ab82e2b70d253d328111e9f916e0 (patch)
tree73097557ec0c77b5e957d2b789c841bc04c2c3c8
parent1a4d18820d551bedcfa03b7e8ca72df87d4b5cfa (diff)
downloadffmpeg-a19796a15ee0ab82e2b70d253d328111e9f916e0.tar.gz
avfilter/vf_edgedetect: fix heap-buffer overflow
Fixes #8275 (cherry picked from commit de598f82f8c3f8000e1948548e8088148e2b1f44) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavfilter/vf_edgedetect.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c
index ca4f715dbf..d0fdd6eb82 100644
--- a/libavfilter/vf_edgedetect.c
+++ b/libavfilter/vf_edgedetect.c
@@ -126,7 +126,8 @@ static void gaussian_blur(AVFilterContext *ctx, int w, int h,
memcpy(dst, src, w); dst += dst_linesize; src += src_linesize;
for (j = 2; j < h - 2; j++) {
dst[0] = src[0];
- dst[1] = src[1];
+ if (w > 1)
+ dst[1] = src[1];
for (i = 2; i < w - 2; i++) {
/* Gaussian mask of size 5x5 with sigma = 1.4 */
dst[i] = ((src[-2*src_linesize + i-2] + src[2*src_linesize + i-2]) * 2
@@ -147,8 +148,10 @@ static void gaussian_blur(AVFilterContext *ctx, int w, int h,
+ src[i+1] * 12
+ src[i+2] * 5) / 159;
}
- dst[i ] = src[i ];
- dst[i + 1] = src[i + 1];
+ if (w > 2)
+ dst[i ] = src[i ];
+ if (w > 3)
+ dst[i + 1] = src[i + 1];
dst += dst_linesize;
src += src_linesize;