From patchwork Fri Sep 4 17:20:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22095 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 4754544B8FE for ; Fri, 4 Sep 2020 20:20:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2175C6882E8; Fri, 4 Sep 2020 20:20:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DB16D687FBB for ; Fri, 4 Sep 2020 20:20:34 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id q9so6748269wmj.2 for ; Fri, 04 Sep 2020 10:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=STylyTzyi5r156aLC6iv1MwUv5SOHpY3YrLJFj/Azhc=; b=OPnesRftz/Tnuo+GlWsc+VzB1ttBrAl9MlGh1r93/YWFnIVUyXUX9hNqJC0PGGIKMB FVpf1lFY7ZO4Tn0W9ZMjyo9q3w2+PLt1uRRu2mMP4BXAbQFOGmVLzF18MwutcZF0sXRN c8bq8tFNW0sOmhz8uayviQvqc2vmqG8OCz18nK3xDgn1p9Or5hee8WvCRcd4aVzwwOK8 FFx+KTvXAwS+ZRCPwDQD8br+xEnaRU7t5aZ0nR47JLD37MvQIsstiNi09CVvgVQitDZr OzCs6YCBnyQ/hyNhzeV3LmspILwUX6wiK7Q3Do7mgJJQyZ3w1KDMMptCj7mcA2VsJPLO nfWg== 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=STylyTzyi5r156aLC6iv1MwUv5SOHpY3YrLJFj/Azhc=; b=NbqYle5gn5OAboMgo9Ssuk52r0O1hrfCSdGeYgLK2YKvE5pH+tBdZ0Jhzaffmn7IOm Mcx3K3KiEOe45ief0GE4ATMFh3bk8tHqZSa4YLOr9/SkFvomsIt1QyH/F5ns4SC/wBaG 8yDHBHRHoiOrsvgVsw+nIUlchB4twyoo1rWXV6irziWXo5e5wHvvBP2WmMzCM0zOj56T UTh2bGTJuzlhwagsOessdbXaCnC7qTS/G78jSd8+esLMjPSX8N3tlvp/bUJ4X/yimrQK uxp90fZBae4LewtCuAqqbCKqHxjEXfdwb7KW9j7LLpMasn5NYzvicl9ttMO8x70g0apK uMfw== X-Gm-Message-State: AOAM5304ZW4/kgYDycGihgxUZBbGgRSNSwT38hE0JoQ9eRk/9ECsfoCJ yHccLty1ELHZZSkuNjkddfCOJFXuOIg= X-Google-Smtp-Source: ABdhPJyK7+Ofhgu0aOjqQfEYtYqYTDZNsdflQQYo2Ed/UrJ1i3tn6pldMS/wIStO9yen9oNs+JDcUw== X-Received: by 2002:a1c:b703:: with SMTP id h3mr8493285wmf.131.1599240034007; Fri, 04 Sep 2020 10:20:34 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id v3sm12282897wmh.6.2020.09.04.10.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 10:20:33 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Sep 2020 19:20:21 +0200 Message-Id: <20200904172026.28217-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] avcodec/bink: Fix memleak upon init failure 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The init function first allocates an AVFrame and then some buffers; if one of the buffers couldn't be allocated, the AVFrame leaks. Solve this by setting the FF_CODEC_CAP_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavcodec/bink.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index f251ab4017..c7ef333bd4 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1381,10 +1381,8 @@ static av_cold int decode_init(AVCodecContext *avctx) ff_hpeldsp_init(&c->hdsp, avctx->flags); ff_binkdsp_init(&c->binkdsp); - if ((ret = init_bundles(c)) < 0) { - free_bundles(c); + if ((ret = init_bundles(c)) < 0) return ret; - } if (c->version == 'b') { if (!binkb_initialised) { @@ -1424,4 +1422,5 @@ AVCodec ff_bink_decoder = { .decode = decode_frame, .flush = flush, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };