From patchwork Mon Sep 7 02:49:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22144 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 1CFF344A09D for ; Mon, 7 Sep 2020 05:58:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D8FF468A609; Mon, 7 Sep 2020 05:58:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A676A68017B for ; Mon, 7 Sep 2020 05:58:38 +0300 (EEST) Received: by mail-lj1-f194.google.com with SMTP id w3so14280747ljo.5 for ; Sun, 06 Sep 2020 19:58:38 -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=df6wun98nVlY1+BW2JhgHLnoNCoi6l1yZ4ILAFMaXVk=; b=S21zXlHUONaibyUzhIvyj4Ign9CWtmzrQRJyJt+6FZD/ZjtlclUYSlVk5ktFLkEKvT yiKdoRTxhq60O7UuvEmVFVMzsOD3F/jLeoemsauL3zLhDGcPdCB0NzAhL59J8QC3Mb9w S9Blhn1veAdOIteOA6I4/0CsUiDyT+bC4efeliddGgUdb65olN9McVKTNAaTwjyWYpAJ 7mn2R1hqYowTpTfKyDFGvzCdnySzmXeBxV9Ynz+uk9Tt4aIZkssu6D2w+Ilapt5g61qf UGDyRLkRWJmUDToKc/0BgWC1NTIqx+DI1sXsL9i73EvjqMMJYyqM5jtSFSjOZBRtJqC2 pkrQ== 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=df6wun98nVlY1+BW2JhgHLnoNCoi6l1yZ4ILAFMaXVk=; b=PeLunCjIHbMAkez5ovNp/RhGaCybrKIyeT0+jwlN6te90KPg42lcSvbt0WjmJK9Kbd fGdaYbTW3agnLq/rf/oIYDLAnq38VQ3hwugMVGzxNgSJ40xgsTVJTmnBaPZE6EKJ0uvY 4R3MwenyBQqdwbkRaxL1ORFwguqCB2B0EaKKcshGfFexN0N19P5v3i75T1gdTXfZhe1Q iH8jsG5nobq+CrnOQ4TzXGhKZAQ+7FA1zgYMTTbZgpk/qeBB+XlppbmLK4g3avNTWWhM zKAr2kOVSCvkOpwsf9JJ3RMXonfxI0pasOAcMBDzTAKVIyhbZHrKMmumuKdMPMdmTSVy A6+A== X-Gm-Message-State: AOAM533ET47J83Us94vA9GWJg5SCH6tzSP7u2bpIhl9XnnK5/85UBZaJ DVDkk0dTwKH5/yST/eKcLxOLBM2QYxY= X-Google-Smtp-Source: ABdhPJxGfEgjN7bCHz2dE7q4FhJ7yJnG46WGXhl01+m6v/ct0WajwqqI0pBUvE97dW2sldKWZHdDEQ== X-Received: by 2002:a50:fe07:: with SMTP id f7mr20345978edt.173.1599447066894; Sun, 06 Sep 2020 19:51:06 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id a15sm13802048eje.16.2020.09.06.19.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 19:51:06 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Sep 2020 04:49:44 +0200 Message-Id: <20200907024952.11697-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200907024952.11697-1-andreas.rheinhardt@gmail.com> References: <20200907024952.11697-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10] avformat/segment: Fix leak of duration/framenumber lists upon error 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 code to free them is not in the segment muxer's deinit function, but in its write_trailer function which means that these lists leak if write_trailer isn't called after their allocation. This happens e.g. if the given lists are invalid (e.g. consisting only of ',' (which delimit entries)), so that parsing them fails and so does the muxer's init function; write_trailer is then never called. This has been fixed by moving the code to free them to the deinit function. Signed-off-by: Andreas Rheinhardt --- libavformat/segment.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 0c9b93725d..0c96c8c50c 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -663,6 +663,8 @@ static void seg_free(AVFormatContext *s) ff_format_io_close(seg->avf, &seg->list_pb); avformat_free_context(seg->avf); seg->avf = NULL; + av_freep(&seg->times); + av_freep(&seg->frames); } static int seg_init(AVFormatContext *s) @@ -991,8 +993,6 @@ fail: ff_format_io_close(s, &seg->list_pb); av_opt_free(seg); - av_freep(&seg->times); - av_freep(&seg->frames); av_freep(&seg->cur_entry.filename); cur = seg->segment_list_entries;