From patchwork Fri Apr 21 06:30:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Levinson X-Patchwork-Id: 3456 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp148199vsd; Thu, 20 Apr 2017 23:30:34 -0700 (PDT) X-Received: by 10.28.27.80 with SMTP id b77mr6435683wmb.16.1492756234077; Thu, 20 Apr 2017 23:30:34 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a9si2250371wrc.284.2017.04.20.23.30.28; Thu, 20 Apr 2017 23:30:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9640D688364; Fri, 21 Apr 2017 09:30:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from white.spiritone.com (white.spiritone.com [216.99.193.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A95F668045B for ; Fri, 21 Apr 2017 09:30:08 +0300 (EEST) Received: from [192.168.3.101] (184-100-196-223.ptld.qwest.net [184.100.196.223]) by white.spiritone.com (Postfix) with ESMTPSA id 9117B734046C for ; Thu, 20 Apr 2017 23:30:15 -0700 (PDT) To: FFmpeg development discussions and patches From: Aaron Levinson Message-ID: <3da3644d-35c8-0943-fe8b-ac334d22ad0b@aracnet.com> Date: Thu, 20 Apr 2017 23:30:13 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] Fixed memory leaks associated with AVStream objects if FF_API_LAVF_AVCTX is defined 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" From 4f27e910aca6dae6642b4d73cf07fa0d6c4b1618 Mon Sep 17 00:00:00 2001 From: Aaron Levinson Date: Thu, 20 Apr 2017 23:20:20 -0700 Subject: [PATCH] Fixed memory leaks associated with AVStream objects if FF_API_LAVF_AVCTX is defined Purpose: Fixed memory leaks associated with AVStream objects if FF_API_LAVF_AVCTX is defined. If FF_API_LAVF_AVCTX is defined, AVStream::codec is set to an AVCodecContext object, and this wasn't being deallocated properly when the AVStream object was freed. While FF_API_LAVF_AVCTX has to do with deprecated functionality, in practice, it will always be defined for typical builds currently, since it is defined in libavformat\version.h if LIBAVFORMAT_VERSION_MAJOR is less than 58, and LIBAVFORMAT_VERSION_MAJOR is currently set to 57. Comments: -- libavformat/utils.c: Now using avcodec_free_context() to properly deallocate st->codec in free_stream() if FF_API_LAVF_AVCTX is defined. --- libavformat/utils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index ba82a76..fbd8b58 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4266,9 +4266,7 @@ static void free_stream(AVStream **pst) av_freep(&st->index_entries); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS - av_freep(&st->codec->extradata); - av_freep(&st->codec->subtitle_header); - av_freep(&st->codec); + avcodec_free_context(&st->codec); FF_ENABLE_DEPRECATION_WARNINGS #endif av_freep(&st->priv_data);