From patchwork Sat Oct 17 07:37:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23036 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 9DA6744A23D for ; Sat, 17 Oct 2020 10:38:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B5D868BABE; Sat, 17 Oct 2020 10:38:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1366568B94D for ; Sat, 17 Oct 2020 10:38:29 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id j7so1819141wrt.9 for ; Sat, 17 Oct 2020 00:38:29 -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=S215sPQwqZlVljejHzGFvveP557FfjfyAr7sDVPAElI=; b=eS5bAYAmGiAli6Hk1cYSXhBRMV69QeSHySYfclbaCKwxWvAvNSymmN/WzHqNRNQDo+ G4r4hDAALYkhA8N7pCygvNRGPSDN5KQXID9eskPGcuWWQSIEr+KxGnBBTk88LZPhAnnd sOMQQrrRN5wM95caeI3rc758KiJ5LNZUTvqvBaeDa+ymRsn+G8UTj+m8uCv5RwdrryD5 V9Kqs1LMUj7GfqDaTY47J537X/LfXEPdO3DAkVhROFJgOPrwgm5YD6fWbMaINJJNi0ak oL0OkbJHBFnu80FKB2D9q4RJWBP2pf1hIRHFeSp5ElZqpYAiYOG19hU38AKnKB0Q+VqH GYrQ== 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=S215sPQwqZlVljejHzGFvveP557FfjfyAr7sDVPAElI=; b=J2+NAv4h2BUl55f1YX1uxIj02kes6xq66Vbu2MTd2BRetbx0SPNcYbS4j0SLXVNZB/ Nlwou596Ah3iY5rbu+qgFaz/s2D1w9vntH6aMtnT2FF09fJuOmgIMea8BPpjNAQ8nel9 fqoe96IvRaESV9qHbdi4dolW8qrff12JQqYADY1pq/IJF5FmtC3PrqlNnCOP/TmI5FDL 9zb5uVrZUOKeSVZrFGQ3GAz70DhcE6xZRz0yF5kRlgdZcKAwY56JNFI8NphWHJ5BBmPW rs6ipCyfmFusYJHorH6z+RKhn/iS01EnH2TdFyhdyXqeMwcrpT9mv7earYnTWEg4Duyw MmmQ== X-Gm-Message-State: AOAM5338Af4vPPpVgX9VDoj7qcXbaI+mQ3q9DUT0IYaY4+gLhMW33Y04 i61IGBHE2FxuLQITgqvbVSNT7dBKMEc= X-Google-Smtp-Source: ABdhPJwpStHIJ1t+8qHRAkEonGCgh0/r5/aTcznzbAyN+RbOvFheLhUhZbV6bfbKyOMgl9EbvxA5sA== X-Received: by 2002:adf:a1cb:: with SMTP id v11mr8380663wrv.86.1602920308343; Sat, 17 Oct 2020 00:38:28 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id 24sm5946553wmg.8.2020.10.17.00.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Oct 2020 00:38:27 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Oct 2020 09:37:45 +0200 Message-Id: <20201017073745.403153-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201017073745.403153-1-andreas.rheinhardt@gmail.com> References: <20201017073745.403153-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 8/8] avcodec/movtextenc: Cleanup generically on init failure 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" Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 2082dc9b25..1bef21e0b9 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -30,6 +30,7 @@ #include "ass_split.h" #include "ass.h" #include "bytestream.h" +#include "internal.h" #define STYLE_FLAG_BOLD (1<<0) #define STYLE_FLAG_ITALIC (1<<1) @@ -331,19 +332,13 @@ static av_cold int mov_text_encode_init(AVCodecContext *avctx) av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); s->ass_ctx = ff_ass_split(avctx->subtitle_header); - if (!s->ass_ctx) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (!s->ass_ctx) + return AVERROR_INVALIDDATA; ret = encode_sample_description(avctx); if (ret < 0) - goto fail; + return ret; return 0; - -fail: - mov_text_encode_close(avctx); - return ret; } // Start a new style box if needed @@ -736,4 +731,5 @@ AVCodec ff_movtext_encoder = { .init = mov_text_encode_init, .encode_sub = mov_text_encode_frame, .close = mov_text_encode_close, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };