From patchwork Tue Apr 10 21:13:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wolenetz X-Patchwork-Id: 8381 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1531606jad; Tue, 10 Apr 2018 14:19:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx49efCSfaM8RIblhAgv0M4EyHc4ZDR1Ck9RtPXEmnMkkukBDcwLhjVZTH1KwuVDv3rk2FGVS X-Received: by 10.223.196.82 with SMTP id a18mr1522700wrg.164.1523395180294; Tue, 10 Apr 2018 14:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523395180; cv=none; d=google.com; s=arc-20160816; b=n9kk/gzcTnW9tmucxZALngrvsTUsUwS15g//rnWd4ZPlrwHg9fOv6TLNvMfbf8rJVN 4TpGpC3OefPJnT71z9sVRf4hA6bLxhPjoHl6w6pUWprtyV6HfCr1EAKRKlee2d6nesTQ lC0cMWYQbswfO1GB0TjxRfcO8Ez/juxXN0vI/Io3n+GMk23Mw0Vo/O08a5gNmEJ6Kkup 1tcr1CB7VY2oQamK2LCUECoc61w/JRf8trnfnb1sED8SzyYdQCQQgM9dha0yoFVDCcHv uoOTB0KUpqd8Wx4sME0Dcc3a1YboJzJBR1wRP9JMZGpdLCt3fRQC1hCczhxmI3v+1DMe eTEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=8jDPq5S+qsLV+T8mFDVSKERMtn1WCaOysInlKyc4h2Y=; b=EJ23QUAWRlhgslQ/BcFqiA9J+3K8+bYFqiPGhY2mvEEBBxKxT4PaIkmpX+wKaNpfz0 usWZIU+oOpTh8KKNaeVQ+i+e45dD+tksQ2PIlGxT4NCg4xtlBf4mdh8OYQ5+n0MXAQLS k7huPlB9s7kAk2zzD4fz+F//JU9XQ9zw1Y2nrGprHnnxLV5Hcu0J4NU34S9bXTacGqIc Ka6fWU3o2x7bjPEOkV9rKliFL5AMwzAwfbKSmamSuRBU4B4kC6eAQaEEr4npSECa2qhC 5/sKgQeK2vX87MUtuO5KSY7mXwG0ATcjRE0BzrV7Et9S8lbydUMJkv5hyZSisVYzdPcc RBZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=Axl51/t2; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v189si1750274wmf.169.2018.04.10.14.19.27; Tue, 10 Apr 2018 14:19:40 -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; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=Axl51/t2; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7FF7868A056; Wed, 11 Apr 2018 00:19:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb0-f169.google.com (mail-yb0-f169.google.com [209.85.213.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0AEDF689B98 for ; Wed, 11 Apr 2018 00:18:56 +0300 (EEST) Received: by mail-yb0-f169.google.com with SMTP id t8-v6so1307013ybo.9 for ; Tue, 10 Apr 2018 14:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:reply-to:from:date:message-id:subject:to; bh=2/SdGbZK3rNrdmME1T4LBxZ9BYFqZHkKZbHp+vVD+rw=; b=Axl51/t2ecpPUmie6KF/5gxB4/YnUJasj79oEfAIyC0ybAuRaOKvAk7Ee+aZaOFt03 tCtwdErswmW+5d7vHOCC9evNsEnOSZoS1VgwcFG22FJrdL0SHrgMjkI0DiDE2hH/JfvY ZOKYKLVuQcnbac4lOEgMoXN9FTD4ompks6xqs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:from:date:message-id :subject:to; bh=2/SdGbZK3rNrdmME1T4LBxZ9BYFqZHkKZbHp+vVD+rw=; b=idJexd2w3oVeo/ZrNLkJF8JY+FpzAIxJSatSuy82NNxq4t8lEChDqBIVp7mKUmH5Rh l/X+q6QBGiuVlFphqgbd4GyNA+k8rwtLHCsZ4fGjEtT9iuoeV760eewk7DmgGc99ns8v pe8xxnqN2OqS08mPBCKh34HOVh6t/wTuP30MqNhJzDJL1CsnuYLQ2g5yddECPbZRCJjF rSnrI/7qBtexrmBHl1PbsdyMT3acl08c1EI+Rrzo0FRR0YRZZevcG9qVKdj636CmwuxD YipfvQFm+yvIGzS+1+XiPodjq8Xv6/glTseI206dDOicjI7U4XHrkBCzFniz9R/tBEph VI6A== X-Gm-Message-State: ALQs6tD4/ck4XSq7nqxJlnG2A76LbazMjacaYaCUbQ3zDfGQsBYAIXCp zTNo10+9Gh+yXPEMe22Ixcs6IiGGUdc= X-Received: by 2002:a25:6215:: with SMTP id w21-v6mr1225815ybb.476.1523394850562; Tue, 10 Apr 2018 14:14:10 -0700 (PDT) Received: from mail-yw0-f169.google.com (mail-yw0-f169.google.com. [209.85.161.169]) by smtp.gmail.com with ESMTPSA id b23sm1754250ywa.45.2018.04.10.14.14.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 14:14:09 -0700 (PDT) Received: by mail-yw0-f169.google.com with SMTP id r29so4507735ywa.12 for ; Tue, 10 Apr 2018 14:14:09 -0700 (PDT) X-Received: by 10.129.242.17 with SMTP id i17mr1176901ywm.117.1523394849150; Tue, 10 Apr 2018 14:14:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:a006:0:0:0:0:0 with HTTP; Tue, 10 Apr 2018 14:13:28 -0700 (PDT) From: Matthew Wolenetz Date: Tue, 10 Apr 2018 14:13:28 -0700 X-Gmail-Original-Message-ID: Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] lavc/libopusdec: Allow avcodec_open2 to call .close 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 031e96bd481b7b8d0c11e5353f74fafc69e37f09 Mon Sep 17 00:00:00 2001 From: Matt Wolenetz Date: Tue, 10 Apr 2018 13:59:25 -0700 Subject: [PATCH] lavc/libopusdec: Allow avcodec_open2 to call .close If there is a decoder initialization failure detected in avcodec_open2 after .init is called, allow graceful decoder .close to prevent leaking libopus decoder allocations. BUG=828526 --- libavcodec/libopusdec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index 3d2ee5b61b..2a97811d18 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -160,7 +160,10 @@ static av_cold int libopus_decode_close(AVCodecContext *avc) { struct libopus_context *opus = avc->priv_data; - opus_multistream_decoder_destroy(opus->dec); + if (opus->dec) { + opus_multistream_decoder_destroy(opus->dec); + opus->dec = NULL; + } return 0; } @@ -252,6 +255,7 @@ AVCodec ff_libopus_decoder = { .decode = libopus_decode, .flush = libopus_flush, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, -- 2.17.0.484.g0c8726318c-goog