The latter code relies upon the dimensions to be not too small; otherwise one will call av_clip() with min > max lateron which aborts in case ASSERT_LEVEL is >= 2 or one will get a nonsense result that may lead to a heap-buffer-overflow/underflow. The latter has happened in ticket #8248 which this commit fixes.
Unified · Split
| @@ -363,6 +363,11 @@ static int config_input(AVFilterLink *inlink) · 362 unmodified lines | ||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | if (mi_ctx->mi_mode == MI_MODE_MCI) { |
| 366 | + if (mi_ctx->b_width < 2 || mi_ctx->b_height < 2) { | |
| 367 | + av_log(inlink->dst, AV_LOG_ERROR, "Height or width < %d\n", | |
| 368 | + 2 * mi_ctx->mb_size); | |
| 369 | + return AVERROR(EINVAL); | |
| 370 | + } | |
| 366 | 371 | mi_ctx->pixel_mvs = av_mallocz_array(width * height, sizeof(PixelMVS)); |
| 367 | 372 | mi_ctx->pixel_weights = av_mallocz_array(width * height, sizeof(PixelWeights)); |
| 368 | 373 | mi_ctx->pixel_refs = av_mallocz_array(width * height, sizeof(PixelRefs)); |