From patchwork Tue Jun 15 23:32:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 28400 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:bbc9:0:0:0:0:0 with SMTP id c9csp125912ybk; Tue, 15 Jun 2021 16:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk8vPB0FSOxexutviKW3W4zb8x4my+KWpVoNRle9gZOm2fWb6PBF9nRD7VczZqF7u1nUmv X-Received: by 2002:a17:906:2f91:: with SMTP id w17mr2074452eji.443.1623800350542; Tue, 15 Jun 2021 16:39:10 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ar15si390295ejc.146.2021.06.15.16.39.09; Tue, 15 Jun 2021 16:39:10 -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=@outlook.com header.s=selector1 header.b="sUsiQ/I2"; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA46068A073; Wed, 16 Jun 2021 02:34:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2083.outbound.protection.outlook.com [40.92.91.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDFBA689CE2 for ; Wed, 16 Jun 2021 02:34:36 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ORRB8lkxqVqi8vfSYsa9zNi09E86uN4EpPnE32gsOsciOFC3sGiJdc75WgB9bfCmQcYj9TUXQGEWZc0sc0ccnKu3wJPnsmsj/stsYwJ0foBGRn8EtgMApHkYSS0B1lX2fzx9e6aZ3h8Z/G7AxNTPm8HC/Hfx7YVDY04Vj5kC+lPR/uoYIGk7mmHu0tj/130gf6c699n7fa9V03+GUYMWF3vMl69cZmLL+J7sUpyZ2L6cmrnHcA/JQ0Jv/Kp9chTlNdqjlrwC1xb9dglv8Fj+fXe1Qtvzq2RzwNOclOA4tfBHWjFF7maOXj5xY2yCxRsxJHu0SJcZL1NgNvwanzARNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dQ8ls3pG1jEsojnp9alkYuodrstSHhJXulGUAoAAw1s=; b=QsriFUhRnNe3Uk77jAmiwf4rxYhI3mU8LIc2uLemjVeERo8mRK1Dewares0oh5GBXmZXddy6rmT0jH3twVDvdNcVBuXJBbKlv0fCzOvQL4ECfpgQKVrAu1G+mMhHRq4Gl2LRV4EkpGuwSmd72ThaEFeViNYaxIQmInRg8bWEpX+mLbG0GtiTBk+VVa/5Qbun9CalYiPdTEMO7Rowq7YngGcq6WtmYiYVE94ieuC5xLZWsBv1nzTrs9ZZBvsuT37NCRj3znqziUuonCdeAZmsuYXKUgFPEOQB+v0+Iecx+Tel8S4MedpXHtM1Q7vGQzf2O1rYu14EQ+R4OcGYI3p2Aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dQ8ls3pG1jEsojnp9alkYuodrstSHhJXulGUAoAAw1s=; b=sUsiQ/I2C693OhmpI+WBeKBm0ALXuvGGmLMs2yX9puoQgU/eJhcTvUrVURGF/iGOu/PxH113QbCrt11ivquWVgE5ifGCH+xgTEf8kRDYCkxfGmWdelN2FOgpMSseXJFsWG/ODfI5L4HUh0DkTuE48I/9q/pmUygLyvL2s6GmHshQ0kuQXx9qZQ3PZXN7VXHrndIPtgSbVKOqNw7LvAhkonNzruU9zSMca2FUVolMT0VbzaKMTFY/uUmNUOHlevkO57CNpMHaMA6vtfa3j2usWrBkdVQLDPP0F1GkFgRq27vv+xUHwy1OXJ3INQybKnmv2M0rmYZpxqra9CMaAKkwLg== Received: from DB8EUR05FT030.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::47) by DB8EUR05HT026.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Tue, 15 Jun 2021 23:34:35 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc0f::40) by DB8EUR05FT030.mail.protection.outlook.com (2a01:111:e400:fc0f::228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.16 via Frontend Transport; Tue, 15 Jun 2021 23:34:35 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:307DF4653028FC151E4290B806FFD233459A8D72CE0A89E587B2A730B0CF8788; UpperCasedChecksum:B232F32BED576FBA4A3EBD30F7220FF0D39E76A927E58B182D98855AD8F1B2CC; SizeAsReceived:7771; Count:50 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb%6]) with mapi id 15.20.4219.025; Tue, 15 Jun 2021 23:34:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Jun 2021 01:32:30 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [XJRQhrP5R0IZH0c02+BsuSAc63mbwTw5] X-ClientProxiedBy: PR3P189CA0063.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::8) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210615233243.1173928-40-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.97.82) by PR3P189CA0063.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.20 via Frontend Transport; Tue, 15 Jun 2021 23:34:12 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: a54fd92b-bc41-4c5e-46e2-08d93056152f X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiR9SlwCHtPrt+MV8TUUwp4p0OETr0+Jrn3q7VUpeBo+bwQx24SGCRTbjJtpS8fRh5jRoANiDogjc273fUftsk2QdtBRnHNVyeF9/TvO6gICbtKlZqiXfQvBqrw2SKVbsuldC7qzzByoXOLCMJ7OrE4aiCcJs9D1DOs+jMdtzWgtnVKW0qnLrgixggbRe5SjI1zo6guLOkkUNXrYdNMbb9r+d2y/H3+7a2a9BvwuSE8GCr+VdXUW8cpxN9H1KOWrT3bX+5ie1YsTEa5fNH7aI9gkvaK5DewKTutvVX1+lg/AbnZUYx+E7cbrX9/iG9y7HVAmOnbck9/0jf5FXfFNOu6vh6Lp2fpf+oXxHEvzaNoQ6sChvlyDGTC7ti2tbd1yLwa3cALQPN/t1Zl7WEInb/WUxl9SNFygqBCNnvPHsttGtIQKEtK+FCHLk9EFrPn0Pwu1K4IceX1U/yrNO85yhOUWa64aD75iLA2mMF2X33IeGMJRODTWwEQwaGjq/BDxnDe9AjtLogqcAEFp0NbyvigdYbXnx1fFj9MkAcRIARsAVROkPjEr9f+8RbwHhyFtA7hY89P1KzQKgtTZVJc6GKo9OdTb67NzpI8PU5kt9s7z8si8+u1XMqb4EMF+faoB2VwdyC6CDtoyx2A/xE67CR/JSoMJc3quF/6P/Mobp7lLYGCcHXdEV4+51ce8uh/RXzrBmoIn4gXHrSEUfaHF7NOrgdMKveTNem6WO4W6lALcXsA4Ty9uk2zLKHq+XBPgySU= X-MS-TrafficTypeDiagnostic: DB8EUR05HT026: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gr9bZQpXydqfFlKx8JS1xHdswS4fD974HEo1aghgb54vxiClMkUj0du19fgwgsCzd0sMQKojPeMrVU3HPDbmqDXw4+AGrJtEf+mW9vSctNI6cic8XX3Q4F+hmH6kRJykZjsLMo1K3KTwHBGVZSL/r1lKImZAH/QqbEyDIyjNUxv5oWgngi7ybvQa/7qyryP/IQ66QnBqpJuV6xGEvGqpaVavkLTRMmreki4e5ye24dJPIfraOv2gw7OD5xNdpvcCADAPtm5jqP8ZH6cK9Vio42pJc9zmFm58AVg1fARdrr1iIkXP62w8DP64EwOhK3fc+aPzFH43nIqH7hAFF4G14I5alay7545b12ffKn2Tsadqhe5Cp3BwP/S8FF0c2EPw5NpxVwzm5lPtgxjUvF7x8w== X-MS-Exchange-AntiSpam-MessageData: xhTly4Iw3lSG5T3FeqvPRf2k6flaMrebHHlGdrlnsyy9LZOBDHwE2dOQShCBZ8eivNQUdRlUx6cWdN6gQqV9wea5NIAoCa8sTcgo+xm1z/QJT1ibaQyRVqiMLuhKxWLnSlH7i5i4Bex7TY63nvM0XA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a54fd92b-bc41-4c5e-46e2-08d93056152f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2021 23:34:13.2945 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB8EUR05FT030.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8EUR05HT026 Subject: [FFmpeg-devel] [PATCH 41/54] avformat/segafilm: Simplify cleanup after read_header failure 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JZNbXvrzTE41 Content-Length: 2545 by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/segafilm.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 05b4d9e6a8..ce1166a05b 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -90,7 +90,7 @@ static int film_read_header(AVFormatContext *s) AVIOContext *pb = s->pb; AVStream *st; unsigned char scratch[256]; - int i, ret; + int i; unsigned int data_offset; unsigned int audio_frame_counter; unsigned int video_frame_counter; @@ -216,17 +216,13 @@ static int film_read_header(AVFormatContext *s) audio_frame_counter = video_frame_counter = 0; for (i = 0; i < film->sample_count; i++) { /* load the next sample record and transfer it to an internal struct */ - if (avio_read(pb, scratch, 16) != 16) { - ret = AVERROR(EIO); - goto fail; - } + if (avio_read(pb, scratch, 16) != 16) + return AVERROR(EIO); film->sample_table[i].sample_offset = data_offset + AV_RB32(&scratch[0]); film->sample_table[i].sample_size = AV_RB32(&scratch[4]); - if (film->sample_table[i].sample_size > INT_MAX / 4) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (film->sample_table[i].sample_size > INT_MAX / 4) + return AVERROR_INVALIDDATA; if (AV_RB32(&scratch[8]) == 0xFFFFFFFF) { film->sample_table[i].stream = film->audio_stream_index; film->sample_table[i].pts = audio_frame_counter; @@ -260,9 +256,6 @@ static int film_read_header(AVFormatContext *s) film->current_sample = 0; return 0; -fail: - film_read_close(s); - return ret; } static int film_read_packet(AVFormatContext *s, @@ -335,6 +328,7 @@ const AVInputFormat ff_segafilm_demuxer = { .name = "film_cpk", .long_name = NULL_IF_CONFIG_SMALL("Sega FILM / CPK"), .priv_data_size = sizeof(FilmDemuxContext), + .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = film_probe, .read_header = film_read_header, .read_packet = film_read_packet,