Hi!

Attached patch allows to work-around ticket #7140, tested on a system
with a lot of memory.

Please review, Carl Eugen
From c9f21979215660d78dfa3e308acf148094522a02 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffm...@gmail.com>
Date: Sat, 28 Mar 2020 13:46:05 +0100
Subject: [PATCH] lavfi/minterpolate: Allow larger allocations if SIZE_MAX is
 big.

Works around ticket #7140.
---
 libavfilter/vf_minterpolate.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index b0bb238ade..452166a2e3 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -361,9 +361,11 @@ static int config_input(AVFilterLink *inlink)
     }
 
     if (mi_ctx->mi_mode == MI_MODE_MCI) {
-        mi_ctx->pixel_mvs = av_mallocz_array(width * height, sizeof(PixelMVS));
-        mi_ctx->pixel_weights = av_mallocz_array(width * height, sizeof(PixelWeights));
-        mi_ctx->pixel_refs = av_mallocz_array(width * height, sizeof(PixelRefs));
+        if ((uint64_t)width * height < SIZE_MAX / 2 / FFMAX3(sizeof(PixelMVS), sizeof(PixelWeights), sizeof(PixelRefs))) {
+            mi_ctx->pixel_mvs = av_mallocz(width * height * sizeof(PixelMVS));
+            mi_ctx->pixel_weights = av_mallocz(width * height * sizeof(PixelWeights));
+            mi_ctx->pixel_refs = av_mallocz(width * height * sizeof(PixelRefs));
+        }
         if (!mi_ctx->pixel_mvs || !mi_ctx->pixel_weights || !mi_ctx->pixel_refs) {
             ret = AVERROR(ENOMEM);
             goto fail;
-- 
2.24.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to