From patchwork Sun Jun 14 22:36:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20356 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 4AECB449042 for ; Mon, 15 Jun 2020 01:38:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33D3968B553; Mon, 15 Jun 2020 01:38:14 +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 6B8B968B310 for ; Mon, 15 Jun 2020 01:38:08 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id j198so12855898wmj.0 for ; Sun, 14 Jun 2020 15:38:08 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=D4fEZO7ava6m+rxWlYkfEM3gC6OwiFsSNYpNSIcEwGA=; b=PALk51KV2bXFy02CnAHaXIqcCbNmQDBGBG2u19NXYE7j0AcMB/N9tNMH9ml1/0f6eg WybOCcCR9/605oWUoj5VFM3j4UVXBSPeSKerUe/SI/HYzqslNOZuFv3/TbKKOUrEicb7 toBIx2LnRDKRHUvQSbhjkMLBcJBo+BTAxThtwrC3iBJbRots87MbGUEglMFI52Sh+ctJ TqNOvEYVbQsRTvK+ujWVm7qRQSZ4E3hyZHVtAsDEbd0sf406jMYeWkpU5nFzqatFtXAE kUHEhudphLmm7bCRZXtPDG2o1IWNgASCZVIQxrXt21XcVbHWZixwRg7K5nN1dAVwo3E7 K67g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=D4fEZO7ava6m+rxWlYkfEM3gC6OwiFsSNYpNSIcEwGA=; b=WzO5QsSohqxZh2NampmjsexNSKsMKaq0d40Xtkk96tSVQpVg8PxqYg/HbgaTKpI33l f/zNWhiBOdFG4EwLA3modh4K61f2XaomRSgZwLYQZ5RiA/TMe4EapovewvzE6Z32/LtK jTSzsr02bNtIVaZ3o5O4oCOYUSehNFfdNDyATXEQr/dHaeTtCCi0QMG1jq2Mw9zl6WYx W8/IkpsYEW5sHwmmf54DBBmb9G6EAgwuke2lGD1ech6OtdU9nngmzzlkrmedC81mbKxk /EjsER5pXwPzioddI32Xqa50hYk7PNMI3rQf5ueaVIOsQC+xcYRANk6kl0rYDsxpwIus q66g== X-Gm-Message-State: AOAM531Iw1azVArYP5ixVFIo7hQpoYK4I7zflDFoxgdTI482uNZd4CPF jre75nlcsLaRqDAcVhVuPZdfx7Ru X-Google-Smtp-Source: ABdhPJw/sSFZUe2jyX9XXBNfsNPNAl5B4Lz/4TEZE+y3qS8CxQMD3ZxJ6ksG/PMasTjS0Q3j+SKOfw== X-Received: by 2002:a1c:bcd5:: with SMTP id m204mr9365569wmf.146.1592174287644; Sun, 14 Jun 2020 15:38:07 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id z8sm21491034wru.33.2020.06.14.15.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 15:38:07 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 00:36:34 +0200 Message-Id: <20200614223656.21338-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/26] avformat/matroskadec: Fix memleaks in WebM DASH manifest demuxer 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" In certain error scenarios, the underlying Matroska demuxer was not properly closed, causing leaks. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d26375cdcc..44beedb4aa 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -4181,14 +4181,17 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) return -1; } if (!matroska->tracks.nb_elem) { - matroska_read_close(s); av_log(s, AV_LOG_ERROR, "No track found\n"); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto fail; } if (!matroska->is_live) { buf = av_asprintf("%g", matroska->duration); - if (!buf) return AVERROR(ENOMEM); + if (!buf) { + ret = AVERROR(ENOMEM); + goto fail; + } av_dict_set(&s->streams[0]->metadata, DURATION, buf, AV_DICT_DONT_STRDUP_VAL); @@ -4211,7 +4214,7 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) ret = webm_dash_manifest_cues(s, init_range); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Error parsing Cues\n"); - return ret; + goto fail; } } @@ -4221,6 +4224,9 @@ static int webm_dash_manifest_read_header(AVFormatContext *s) matroska->bandwidth, 0); } return 0; +fail: + matroska_read_close(s); + return ret; } static int webm_dash_manifest_read_packet(AVFormatContext *s, AVPacket *pkt)