From patchwork Tue Oct 13 01:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Miceli X-Patchwork-Id: 22893 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 B91EC44B82C for ; Tue, 13 Oct 2020 04:28:58 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89EC668BB42; Tue, 13 Oct 2020 04:28:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD05868BB10 for ; Tue, 13 Oct 2020 04:28:52 +0300 (EEST) Received: by mail-pg1-f193.google.com with SMTP id b193so15372824pga.6 for ; Mon, 12 Oct 2020 18:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miceli-net-au.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=J9lzy1Tg2oWEsxGAi3v+iyuKUKhkzvTISlJupZGynxc=; b=EbQ/D+4lSTuXWG3Zr4LO8AKFhMF23h2J4uBntmXvfnTt8sZs+MBwG2x2a9wzdrO8a0 wxR1DGR/pf0evIbzPp0LAlLMeOn7Ev4xlQ5gzZQwh3Lo4UnHQ0UOuW5hdQnOV//rM2Xy nod5J35ox4RM4yXkDOgviM5We+2ktpSVcwzb2JZgT2RgM6zKELG6KRGNBW5ill4fU6Rv ug6aHYr4bvg+zp1yrfdvhNbTAQwImuGXEFOEdHfdY8UFDvme/EHYHVnKoEn/FVDsYjGJ 9A/A1hjl6nGryJMiL8AvmDCYKj4jnzCrMNAdhP93sVn5O6VxL92fQmrDz3ceSHYMzWg6 KqAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=J9lzy1Tg2oWEsxGAi3v+iyuKUKhkzvTISlJupZGynxc=; b=tsiPAS6Tg3y7Fa4yz34tqJCkvWQpJKDA3yoqisRHr5fQzPqf0fB7LkDzQmvOQChC5L nTufyD7hsJ6+Fj8qOwMaM8nB91p+qTwvPXchAYsd8f4/0cUFfdhuvqgquVJ3yKSw0ToB BNu186mUqSPaa/pzHwI0BPvVzFdCjDqF24TmLzJ15vMB+XOaS9Ffgw2OpjZYFbmtxO2I s4dCfawHrzZgTxHDfmnT43tJvTy5WAnd79sGvXPF94aE9WzcLsmTwXvKZipUhWeHPv+q cc4kbJ2dSUlVL83Blz2xRzhGPiP8Z/FqRUkPFGVQDM1csIEWO5tsxp+hwESRVme/iVWa Wv2A== X-Gm-Message-State: AOAM531aNvojx4DZQzcGHd60CzA3v7gR1HZ/5O30POcacFpv+s6J21Kx D8xl3ShCMn9iPakl0MPuAVD1BBie9aCcorZB X-Google-Smtp-Source: ABdhPJyav6OGp8uRn0CsgLnNGcupaL+0AdY0MI1nZVaugo8h1/Kj00aBkuwUiWuXNItznkObDzIOFA== X-Received: by 2002:a17:902:9698:b029:d1:9492:745b with SMTP id n24-20020a1709029698b02900d19492745bmr26906368plp.26.1602551233096; Mon, 12 Oct 2020 18:07:13 -0700 (PDT) Received: from edna.localdomain (119-18-3-107.771203.syd.nbn.aussiebb.net. [119.18.3.107]) by smtp.gmail.com with ESMTPSA id q8sm16167449pfg.118.2020.10.12.18.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 18:07:12 -0700 (PDT) From: Chris Miceli To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Oct 2020 12:07:01 +1100 Message-Id: <20201013010701.53885-1-chris@miceli.net.au> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavfilter/af_mcompand: Check for failure to allocate memory 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 Cc: Chris Miceli Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" ticket 8931 mentions some missing null pointer checks and so this is one diff of a few which are for these fixes. There are previous code pieces which return ENOMEM, so this should work as intended. --- libavfilter/af_mcompand.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c index f142573bea..953f7cd407 100644 --- a/libavfilter/af_mcompand.c +++ b/libavfilter/af_mcompand.c @@ -386,8 +386,20 @@ static int config_output(AVFilterLink *outlink) } s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double)); + if (!s->bands[i].attack_rate) { + av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for the attack_rate\n"); + return AVERROR(ENOMEM); + } s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double)); + if (!s->bands[i].decay_rate) { + av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for the decay_rate\n"); + return AVERROR(ENOMEM); + } s->bands[i].volume = av_calloc(outlink->channels, sizeof(double)); + if (!s->bands[i].volume) { + av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for the volume\n"); + return AVERROR(ENOMEM); + } for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) { char *tstr3 = av_strtok(p3, ",", &saveptr3);