From patchwork Sun Nov 13 22:25:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1409 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp775026vsb; Sun, 13 Nov 2016 14:25:42 -0800 (PST) X-Received: by 10.28.221.11 with SMTP id u11mr8177169wmg.123.1479075942042; Sun, 13 Nov 2016 14:25:42 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ay9si21053715wjc.120.2016.11.13.14.25.41; Sun, 13 Nov 2016 14:25:42 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@googlemail.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; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7CD0F689D8E; Mon, 14 Nov 2016 00:25:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D062689942 for ; Mon, 14 Nov 2016 00:25:34 +0200 (EET) Received: by mail-wm0-f66.google.com with SMTP id u144so10797771wmu.0 for ; Sun, 13 Nov 2016 14:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=sstGFyp+RyjLkazgPkvyYughokE1OhYXdQhRNko50F8=; b=xQFNthFZ++cksbu26xa38MYy5DIXR7wuD1uAJ8CN3eEtycZdT28igVXTcfp0FOGz6Z nwBnCFpWBy0UzBwSyMB//wNZUvh2ZmOAnTLCWbhie70caOOx1+dj/N3gmBP7V1pAjCWc hqoWlavNm5vMG0vIjO8rWTQbYDmDah1oJ6y4coMJBBnEOf6h55miZOkqDTVLMYCCU4vK WbQltrM5MiZk5pcWWfrh2JGUFdvRjFtDcjcdi0CIw9lAya+1m4jLMEQQ+0HdQqDfohB2 EGKlZcsbxdn6SxnA2DdZoQiCBp6tkxbFnUZWq2gNxw0mmmHdPvVNp2aV+XlAGdID8qd/ JbrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=sstGFyp+RyjLkazgPkvyYughokE1OhYXdQhRNko50F8=; b=Lnakiy/WSksihc2C41JeK33dTocIiholJ30M1K/CHj83Kzku84vrDu9b8QU4I5BWcD Gq+CoQB+ocQTIvuRdcloEQUET7p0GzmdLeFJsQzBuqRwQkzrl8MqQdmd0+c4kXSP5OPO RDT5lsWej1xwAj5HxrNvz8lcPd4+6W/onNLzx/9Hc9yFYDmIUkv3lU+FHGoja2H+F7us CisF5HD0iubXR+XDBLZMzHs67pT4f3vztAzy0FiX/O4zl6Hk2zr1W08mJGvG4SlDherL YJu+kU3M3M8fT3JeqJVQi3PYAiEP8w7+YOeZ19xHykjztPVYF9mf1GL5jMbnmu89EJaM 3JhQ== X-Gm-Message-State: ABUngvf+X1ELCsW/4Xj2vxLUSwlfn+f/Hh5J1Omcjk0B89hlIRmJJhN6xv2wamAjmJXYgA== X-Received: by 10.28.24.74 with SMTP id 71mr7837045wmy.74.1479075933536; Sun, 13 Nov 2016 14:25:33 -0800 (PST) Received: from [192.168.2.21] (p5B072E6F.dip0.t-ipconnect.de. [91.7.46.111]) by smtp.googlemail.com with ESMTPSA id o143sm25550139wmd.7.2016.11.13.14.25.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2016 14:25:33 -0800 (PST) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: FFmpeg development discussions and patches , libav development References: <5e79953b-5f6e-51ea-927a-84bbe87042df@googlemail.com> Message-ID: <301ff917-83b3-7036-c3e4-bbfe84279e59@googlemail.com> Date: Sun, 13 Nov 2016 23:25:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <5e79953b-5f6e-51ea-927a-84bbe87042df@googlemail.com> Subject: [FFmpeg-devel] [PATCH 2/2] libschroedingerdec: fix leaking of framewithpts 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" Signed-off-by: Andreas Cadhalpun --- libavcodec/libschroedingerdec.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index 1e392b3..83c790c 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -218,6 +218,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, int outer = 1; SchroParseUnitContext parse_ctx; LibSchroFrameContext *framewithpts = NULL; + int ret; *got_frame = 0; @@ -236,7 +237,8 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, enc_buf->tag = schro_tag_new(av_malloc(sizeof(int64_t)), av_free); if (!enc_buf->tag->value) { av_log(avctx, AV_LOG_ERROR, "Unable to allocate SchroTag\n"); - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto end; } AV_WN(64, enc_buf->tag->value, pts); /* Push buffer into decoder. */ @@ -267,8 +269,10 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, /* Decoder needs a frame - create one and push it in. */ frame = ff_create_schro_frame(avctx, p_schro_params->frame_format); - if (!frame) - return AVERROR(ENOMEM); + if (!frame) { + ret = AVERROR(ENOMEM); + goto end; + } schro_decoder_add_output_picture(decoder, frame); break; @@ -282,7 +286,8 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, framewithpts = av_malloc(sizeof(LibSchroFrameContext)); if (!framewithpts) { av_log(avctx, AV_LOG_ERROR, "Unable to allocate FrameWithPts\n"); - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto end; } framewithpts->frame = frame; framewithpts->pts = AV_RN64(tag->value); @@ -298,7 +303,8 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, break; case SCHRO_DECODER_ERROR: - return -1; + ret = -1; + goto end; break; } } @@ -308,10 +314,9 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx, framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue); if (framewithpts && framewithpts->frame && framewithpts->frame->components[0].stride) { - int ret; - if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0) - return ret; + if ((ret = ff_get_buffer(avctx, avframe, 0)) < 0) {} + goto end; memcpy(avframe->data[0], framewithpts->frame->components[0].data, @@ -345,7 +350,10 @@ FF_ENABLE_DEPRECATION_WARNINGS data = NULL; *got_frame = 0; } - return buf_size; + ret = buf_size; +end: + av_freep(&framewithpts); + return ret; }