From patchwork Tue Nov 15 20:56:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1435 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1811410vsb; Tue, 15 Nov 2016 12:56:28 -0800 (PST) X-Received: by 10.28.67.69 with SMTP id q66mr5512284wma.22.1479243388813; Tue, 15 Nov 2016 12:56:28 -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 ul2si30091396wjb.158.2016.11.15.12.56.28; Tue, 15 Nov 2016 12:56:28 -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 B3A6F689A7C; Tue, 15 Nov 2016 22:56:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 86EE8689A26 for ; Tue, 15 Nov 2016 22:56:19 +0200 (EET) Received: by mail-wm0-f68.google.com with SMTP id m203so4050580wma.3 for ; Tue, 15 Nov 2016 12:56:20 -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; bh=fUFwhq5bCGP5dB6lLsI+NqqdzuhsvQiN7F6g/x7O9KM=; b=Tvqqo806QWFz2CUwWi668+8n4BetpT6J1gkNYH8/w70F0TaMHwGrzGI5LcKkJ73lIS rCfaLpBRImDPLrSk2b6ssRWPMrYDar0Wap0HKO8L8b+Mgh+8tVb0yAGujj9C/4bRvlNj 8LPF8OTFqMHheN/ZoSQlJMR1SymPjFARNZv3U6xnFipmubA171oxOnUSL7b1XFMQLFtm PSmUEEh8fDTxjqHedgu6n40m0DKr/ky9+xq47qY4+Wdpfh94uwKq+s2luOnwp3xEX4K5 gqkJP4A44UNppxmlyBACfxnLpeYnOd4JE0KF6LnoygyM40m3PgFGhr22ljwFZAAkwFef Tc7A== 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; bh=fUFwhq5bCGP5dB6lLsI+NqqdzuhsvQiN7F6g/x7O9KM=; b=Sci5fsdtlfWgxOg1pw9flP/w4r9IrbD7mvvMb7PyPfvE3G60v4ia8uLDAWY4v4Qi2u kF9/8CCJI015EvbZbC0JhN1dKtWMgq/aqG1KKrh9iNanh9/LjaY/XNrNsPyvLFwd+RBx sgYh0WEaaGUoHbe0Xt+nf6YdlcFajlrqly5EzfHsafmSfOt6HwRvKld6b4EHREWN3Is3 1D1EZqPtS2tZJ8tCLIqrt+T4PVtlcq0/TAmaQKTmD3DVpS9KsyHdASyVLsiREaxFvd9u XcxKasLGKXLlq6D3eImS5tFzFrx7w5BtvEoV5SHBx9KtIqKkJRMUx/jWQ0PZCr/uC5Ip pwEQ== X-Gm-Message-State: ABUngvcbZJdd7SB1Y11f8uSlrSHGHZCy1yCywc/LBPdD8CxD6hoWMkB/fy/vKBxCecV7fQ== X-Received: by 10.28.107.77 with SMTP id g74mr5632208wmc.109.1479243379271; Tue, 15 Nov 2016 12:56:19 -0800 (PST) Received: from [192.168.2.21] (p5B095CE1.dip0.t-ipconnect.de. [91.9.92.225]) by smtp.googlemail.com with ESMTPSA id c81sm6162928wmf.22.2016.11.15.12.56.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 12:56:18 -0800 (PST) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: ffmpeg-devel@ffmpeg.org References: <5e79953b-5f6e-51ea-927a-84bbe87042df@googlemail.com> <301ff917-83b3-7036-c3e4-bbfe84279e59@googlemail.com> <20161115021810.GY4824@nb4> Message-ID: <81d313d1-f9ff-3e50-b855-08eb99aa010d@googlemail.com> Date: Tue, 15 Nov 2016 21:56:16 +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: <20161115021810.GY4824@nb4> Subject: Re: [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" On 15.11.2016 03:18, Michael Niedermayer wrote: > On Sun, Nov 13, 2016 at 11:25:32PM +0100, Andreas Cadhalpun wrote: >> 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; >> > > this looks a bit strange > framewithpts is set to newly allocated memory below which is injected > into the que and IIUC that can occur multiple times > the free at the end for one of multiple such que entries feels wrong Indeed, only the framewithpts returned from ff_schro_queue_pop needs to be freed. New patch is attached. However, considering the sheer amount of crashes in libschroedinger and that it's apparently not maintained anymore, it might be better to simply remove this decoder. Best regards, Andreas From 9cf7226543e25e494bed768b73f39e67d89f25d1 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Sun, 13 Nov 2016 23:10:06 +0100 Subject: [PATCH] libschroedingerdec: fix leaking of framewithpts Signed-off-by: Andreas Cadhalpun --- libavcodec/libschroedingerdec.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index 1e392b3..02cbe57 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; @@ -308,10 +309,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; + goto end; memcpy(avframe->data[0], framewithpts->frame->components[0].data, @@ -337,15 +337,17 @@ FF_ENABLE_DEPRECATION_WARNINGS avframe->linesize[2] = framewithpts->frame->components[2].stride; *got_frame = 1; - - /* Now free the frame resources. */ - libschroedinger_decode_frame_free(framewithpts->frame); - av_free(framewithpts); } else { data = NULL; *got_frame = 0; } - return buf_size; + ret = buf_size; +end: + /* Now free the frame resources. */ + if (framewithpts && framewithpts->frame) + libschroedinger_decode_frame_free(framewithpts->frame); + av_freep(&framewithpts); + return ret; } -- 2.10.2