From patchwork Sat Mar 28 12:54:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 18456 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3B3F544BD7C for ; Sat, 28 Mar 2020 14:54:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D00E68B5A9; Sat, 28 Mar 2020 14:54:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA33968B4B2 for ; Sat, 28 Mar 2020 14:54:34 +0200 (EET) Received: by mail-io1-f47.google.com with SMTP id r25so879853ioc.11 for ; Sat, 28 Mar 2020 05:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=7TEKWpqfwhCFXwt/DgAaU6mGi9Vbi6OoeMKBH2AWIPA=; b=G8x1ljCDkYWg+CEkFpAQhTRHCN9SzezHbd86cJSWQvKEknP51eEXnefOjkKXcOQuLJ STKaLUlJPM2ij/hEt8Xxxj4M0Cjcl1llTPvUJ+4rwgqxwZ/VUsdpuWvKtOvPstKmGU+3 wWCiyXylIjZMIdIvnswGTvj2olElU29yXk4gpXjldolzHOpkRfNfBa1Ch0i3ERzSv2aA ixQPFS9X21m8rpQckWi9ZC8lqYiEs8uhJekDy4t4xhf9KNQol6WVsF+G7k80S630WWnn BiEke6H0+vUVhgvAHXE0Mm568Np/IbVXvjnrp7o3RAfNgaiWh9trXupRJYT6+ZjY/PUk t75A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=7TEKWpqfwhCFXwt/DgAaU6mGi9Vbi6OoeMKBH2AWIPA=; b=P1xoNQNzVV3CKTvMh3rt7huXFyv2/EUYYUzYK+so1kmlG7pDW014q8lM43l6lHaSG9 CZuNz+aLRS0v2bq8LE6XbIkhpDsrlOdFEABXMCk7joK0RVfTgcBHnEhAOOyjMvBPfPa/ 9GZAKBv3oe2vwyCgVDzPv3dVPF+CO5OoisYPnzGKtFAb4D/vG/8xQ8PXc6K4S9s58iCn wIUgUgeaYyXiVJUUohK+hGbBFHY4ynwfqZrGh9YTg8GPbojz7sU9o96WZ2iNiQU8SX/T 9mi8aZht8amp9qsJAnAnUtJDxVoL6VCtXx5crVwx4rSWrEYG6rh28WpIHBG9uZZE4zM6 l/Qw== X-Gm-Message-State: ANhLgQ31R1LoLjMUNlnbF9VWQKQd9VfCK2Sf18dXI9kru9u/0/GzLtl5 F5wHPfY5R0s6+XCbHzoicWpPML/CWbm9hGiVfsdlkQ== X-Google-Smtp-Source: ADFU+vu3hF+sS1v1N0/bEjzVGHWQjqndotetnvquxMDXmQMNnR5ohc+Fvh0XJQmR4wNayV4e7FxQbgjTdko4fniA4Hg= X-Received: by 2002:a6b:c916:: with SMTP id z22mr2957095iof.138.1585400073567; Sat, 28 Mar 2020 05:54:33 -0700 (PDT) MIME-Version: 1.0 From: Carl Eugen Hoyos Date: Sat, 28 Mar 2020 13:54:22 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavfi/minterpolate: Allow bigger resolutions if SIZE_MAX is big X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 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