From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 1029545A54 for ; Thu, 13 Jul 2023 10:57:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C9C068C645; Thu, 13 Jul 2023 13:57:49 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB39868C32F for ; Thu, 13 Jul 2023 13:57:42 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6FEBB2404EE for ; Thu, 13 Jul 2023 12:57:42 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id eui5P5PxxVJW for ; Thu, 13 Jul 2023 12:57:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6EF482404F8 for ; Thu, 13 Jul 2023 12:57:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 205153A1074 for ; Thu, 13 Jul 2023 12:57:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jul 2023 12:55:24 +0200 Message-Id: <20230713105553.21052-4-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713105553.21052-1-anton@khirnov.net> References: <20230713105553.21052-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/33] fftools/ffmpeg_demux: forward errors from dump_attachment() instead of aborting X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Also, check the return code of avio_close(). --- fftools/ffmpeg_demux.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 40bbfa0c0e..498830098d 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1259,7 +1259,7 @@ static void ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ist->codec_desc = avcodec_descriptor_get(ist->par->codec_id); } -static void dump_attachment(InputStream *ist, const char *filename) +static int dump_attachment(InputStream *ist, const char *filename) { AVStream *st = ist->st; int ret; @@ -1268,13 +1268,13 @@ static void dump_attachment(InputStream *ist, const char *filename) if (!st->codecpar->extradata_size) { av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n"); - return; + return 0; } if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) filename = e->value; if (!*filename) { av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag"); - exit_program(1); + return AVERROR(EINVAL); } assert_file_overwrite(filename); @@ -1282,11 +1282,13 @@ static void dump_attachment(InputStream *ist, const char *filename) if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) { av_log(ist, AV_LOG_FATAL, "Could not open file %s for writing.\n", filename); - exit_program(1); + return ret; } avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size); - avio_close(out); + ret = avio_close(out); + + return ret; } static const char *input_file_item_name(void *obj) @@ -1617,8 +1619,11 @@ int ifile_open(const OptionsContext *o, const char *filename) for (j = 0; j < f->nb_streams; j++) { InputStream *ist = f->streams[j]; - if (check_stream_specifier(ic, ist->st, o->dump_attachment[i].specifier) == 1) - dump_attachment(ist, o->dump_attachment[i].u.str); + if (check_stream_specifier(ic, ist->st, o->dump_attachment[i].specifier) == 1) { + ret = dump_attachment(ist, o->dump_attachment[i].u.str); + if (ret < 0) + return ret; + } } } -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".