Commit bd9ff77306 for ffmpeg
commit bd9ff7730625567c423f3aa3ea847e1f0f448b17
Author: zhang xingxing <2388969553@qq.com>
Date: Mon Sep 21 06:14:25 2026 +0200
avfilter/vf_libopencv: reject custom shape files without columns
Fixes: division by 0
Fixes: 4MBWdnTTajBU
Fixes: swarm-Division-by-zero-when-shape-file-has-no-non-newline-columns-059deb
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 5985262966..5552fab1b8 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -154,6 +154,11 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
}
w++;
}
+ if (*cols == 0) {
+ av_log(log_ctx, AV_LOG_ERROR, "No columns in the shape file\n");
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
if (*rows > (SIZE_MAX / sizeof(int) / *cols)) {
av_log(log_ctx, AV_LOG_ERROR, "File with size %dx%d is too big\n",
*rows, *cols);