From patchwork Tue Jun 15 23:32:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 28405 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:bbc9:0:0:0:0:0 with SMTP id c9csp125462ybk; Tue, 15 Jun 2021 16:38:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg+ZpeFnAzje5XIlZtRA6G1BZ7ORadM3W1Qt3qfbBNaXEkAG5bC9Dp3iZnFrRLEK97fbfJ X-Received: by 2002:a17:906:b2d6:: with SMTP id cf22mr2048110ejb.29.1623800313536; Tue, 15 Jun 2021 16:38:33 -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 j4si452408ejj.545.2021.06.15.16.38.33; Tue, 15 Jun 2021 16:38:33 -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=ZwP9rwPn; 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 BD2FA689F86; Wed, 16 Jun 2021 02:34:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2068.outbound.protection.outlook.com [40.92.90.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B8C6689EC9 for ; Wed, 16 Jun 2021 02:34:34 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KSRMJU9VgK58ArqILWYTjOWYE8imw5XJcG99w+f4a6+92wCYdNDuxPtCpWN3BhP0aaqUHy1xeqlHPWLWpWGD6GcHXCz1vmzow7z9brGW9YDGeEMKlKXvzwPiKJpfL2hXiJUCUf1jzrmpgZV1/bSI5wtu7jTQ+kFAkVZkhIfcSBPijxNkd3+zks+xJMPj3BONhYv3Lit1tf7cAvbQ5eHLIx68OrHXpOAV6mGD4ecKfFLZnPz1HKDHVuT2KYoJfjr85RNDjV2AzmfhJSF2b7g37IHUALzAowhk4TDa7CElKfXvvfwghiosZxH21C0FZYsYNdj+3YQVF42l5myWZxRHrA== 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=RZDSMXJcFIAFTuja8C8Jtu7gqdToUGCm4MC5vpWGUo8=; b=DlWAi3RlF9rr8APvBV/HzzD3QTjXNGcn+vPPZL0AUOcbqM3uefx24MSndKTX9UPwJhwCw2ZOirkDSVlEuKZFNQ/KuKQ9nVNB0pwDXyGrvNx8S4lZv3Prw0ujstrQvL0j6PX2Jsg6YEYwAfUUtY36iD/cmmEURbdnqDqGo4LMqw7SEzTkiA/AT7UdpIEI8QPK/MQrnYsGnEMdiRyAiCWSUssvEBypo1r6a9A5kmtb7Wz4V2Oice3qeXJpRLqbS6d2sg5+gP7glO+PqB8cFEKKTU+IcOCw4NrjSfW3orqpUZ6d7yLRbkSavk5ncUkz4eCGPcMDhjfqVv+LVGFU9CHx/Q== 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=RZDSMXJcFIAFTuja8C8Jtu7gqdToUGCm4MC5vpWGUo8=; b=ZwP9rwPnzrmyTgzJvBQBv6uU6aKQvPszOAyeIOOR/cYmvJDdj7GTSNkzDsoZWVvPzG8902jcgqwybAlUarvc2WsfKvJgfaWhfBq1R7R75IKcTzQk5yjwiP+RrQVAf9jSWe4F28xf3DrVBYOBqSzEKfjQ8Ju6S4UKd3KYmbs1361rsqZefBOAnRDz/HdcAPUUnh4IRTJq8+riLMng+pyPr1kIxnldCiax0iqqzWtL6RQjlwdKqRJnHu6v4OF2/Q/2NXBwU8e0UOzFCaK/bBeID3AlYDpbhIbOhlG/QpUM11HctVA8HNuUd8HnK02WaihjbVfIoajhF5PsDq/MmsWS8A== Received: from DB8EUR05FT030.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::40) by DB8EUR05HT101.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::70) 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:33 +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:33 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3DC44A8CEB4B029D87840E4BA18D4A552AE0D6265B6A3BB77E15CA2EB0D37E91; UpperCasedChecksum:D04E65688CEC7F6C65D4758BA6CC19C8CE17D0E31085BBE5C9839B59428E2C6C; SizeAsReceived:7769; 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:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Jun 2021 01:32:25 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [g2n13eOiehTsS/Ggx1I9leoOcSknIZ9W] 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-35-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:06 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 24aca0d3-1748-49e8-1f04-08d930561124 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiR9SlwCHtPrt+MV8TUUwp4pxqvSbscfQ5pryE8dPqh0BCBhR040DPFGvUlq0QrJnZHhB3J6VjdG/2J+/olHksuufwHaFXbfs8VsBKlOuw5jXqzh6kM21oXw1yYSUgftu/GGnPf2B6rpCItRZX67RIvrMhXuh9FhaArQ15uKTOHOQW/kxsFWMPLGw4GlyEE4+pqTG9YYSwmzZWJoZsIA7L1nXk0cfAQZvkmlzLkmTCRPHr8G+Ko8RkJRSzvfkb4/XJQ5ioz7ygHA1DujjNeXTspq9kDJGA4pjkkJJJ/J1i0hHu8PELS+FgBf6FSLTEzh0b7ScamqtFGtlexhX9HHE9jzgzmfnSL8GoLI2FHlFG+2DN4M1doXhRMnvDzWDBxO0ZkEB1AKtlTtEMLf64SieyeoCLZkQE2Fuy8kjVifCnHXJ0QqsZFyLkQT30jo5rYqDaLJ+BzdS4Zrw3gRLzHXAg+78I56mr4wqxbTObIj6qXcyfuF5DD57dnuNYgTdRt7qPlhXDutHoOnoWugB0iSCSGOkB4GXfqDWez8Q4y9ld658VUqnrpQNi5YGZndC1Tv6LgmRwJ3Ypniz9+NJxLHWaUZ6C8CN5v0YSiLiT8CIgzbfuw1EyWcDP3jkxJXBqeic3uXid7fNn++hYVS9qZ40gKYzx+4FKN8Ke+GO2asqZOEqLbtAnKjIoGYqllhsVmXQ7P/Tkp+OsDp1C7ufrS47hvFr1JEfXcaNQWW6vP4G9emfWBCejLUO0xSe/6XEAEOveA= X-MS-TrafficTypeDiagnostic: DB8EUR05HT101: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0mkVlJ2OXoXplIZObInTbanjoBFtXVDRTwsHDomkSiIOgio7doid7idK8XdzKc0msbojJBzMv7R/RTw0ifBp7xQbG9cL8Wi/G1GlPo6DY9zxetOPAaw7LmfZjtvmVQHe45VArUVo14t6BoVuC1Zcqi6nVuOKjNjlNoao73hLqp0XO21NtTvgyftG0S6qVUVc27cMTC3FnrlfvJRmF8ApwkVMvSVj2yD4FLkXEo9X+z0/SPRmJxHEMtYTVlOx6C/00l7qFiQN0PWh8NUj93SBHnckzUqlipVjIUO+QgqKdRURHMQbqf+K87pLpYT69vcU7gDPJ4hcTIp7ZfIMBWMr+fiUowU/vquIhLhbEUFsMBzANheeVHlgwZ2rfIKg9UU+CMgpHwUZQL4xBABpjd33Ew== X-MS-Exchange-AntiSpam-MessageData: sB3fw2ETEsg4I8fAY164HOfWZyoVEHzg8TsIfdlsQ7J+2zpZu8QNtgAQlSNnYhYUZ62cI3myjcStP7fjbdO6f8S/Y1Aafvp6rrr5mo76/Q2RP/esmpX+gOv/47+VNHKS8nRAjDtWV/5Gg7QRpINdaQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24aca0d3-1748-49e8-1f04-08d930561124 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2021 23:34:06.5085 (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: DB8EUR05HT101 Subject: [FFmpeg-devel] [PATCH 36/54] avformat/pp_bnk: 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: wX27fTSKkv4/ Content-Length: 3314 by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/pp_bnk.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c index 9455a575b7..c500ac7d9e 100644 --- a/libavformat/pp_bnk.c +++ b/libavformat/pp_bnk.c @@ -144,7 +144,7 @@ static int pp_bnk_read_header(AVFormatContext *s) ret = avio_read(s->pb, buf, PP_BNK_TRACK_SIZE); if (ret < 0 && ret != AVERROR_EOF) - goto fail; + return ret; /* Short byte-count or EOF, we have a truncated file. */ if (ret != PP_BNK_TRACK_SIZE) { @@ -157,15 +157,12 @@ static int pp_bnk_read_header(AVFormatContext *s) pp_bnk_parse_track(&e, buf); /* The individual sample rates of all tracks must match that of the file header. */ - if (e.sample_rate != hdr.sample_rate) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (e.sample_rate != hdr.sample_rate) + return AVERROR_INVALIDDATA; if (e.always1_1 != 1 || e.always1_2 != 1) { avpriv_request_sample(s, "Non-one track header values"); - ret = AVERROR_PATCHWELCOME; - goto fail; + return AVERROR_PATCHWELCOME; } trk->data_offset = avio_tell(s->pb); @@ -185,15 +182,13 @@ static int pp_bnk_read_header(AVFormatContext *s) i, ctx->track_count); break; } else if (ret < 0) { - goto fail; + return ret; } } /* File is only a header. */ - if (ctx->track_count == 0) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (ctx->track_count == 0) + return AVERROR_INVALIDDATA; ctx->is_music = (hdr.flags & PP_BNK_FLAG_MUSIC) && (ctx->track_count == 2) && @@ -201,10 +196,8 @@ static int pp_bnk_read_header(AVFormatContext *s) /* Build the streams. */ for (int i = 0; i < (ctx->is_music ? 1 : ctx->track_count); i++) { - if (!(st = avformat_new_stream(s, NULL))) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!(st = avformat_new_stream(s, NULL))) + return AVERROR(ENOMEM); par = st->codecpar; par->codec_type = AVMEDIA_TYPE_AUDIO; @@ -231,10 +224,6 @@ static int pp_bnk_read_header(AVFormatContext *s) } return 0; - -fail: - av_freep(&ctx->tracks); - return ret; } static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -336,6 +325,7 @@ const AVInputFormat ff_pp_bnk_demuxer = { .name = "pp_bnk", .long_name = NULL_IF_CONFIG_SMALL("Pro Pinball Series Soundbank"), .priv_data_size = sizeof(PPBnkCtx), + .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = pp_bnk_probe, .read_header = pp_bnk_read_header, .read_packet = pp_bnk_read_packet,