From patchwork Tue Jun 15 23:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 28352 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp4319520iol; Tue, 15 Jun 2021 16:48:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypHbFdOIauBSpyN+C9xBzJPQJMRx7uC6Y4eejiv39hN9xo97UBOeUsQ2A/udMwgpA9YQhk X-Received: by 2002:a17:907:2be5:: with SMTP id gv37mr2154753ejc.237.1623800926171; Tue, 15 Jun 2021 16:48:46 -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 p1si312593edw.127.2021.06.15.16.48.45; Tue, 15 Jun 2021 16:48:46 -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=eqQpqpEn; 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 86C57689BBA; Wed, 16 Jun 2021 02:48:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2091.outbound.protection.outlook.com [40.92.89.91]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 61817688081 for ; Wed, 16 Jun 2021 02:48:36 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/jxka09NkZpFYs9dMhkFq0Va8LS6sBO6bBZI3mUuDJ3eO2pRaongV/7TUReem/NQUnfyTuJOohMFcEKWUl95xeWFsRA+jGSRq33WkvbJ6llmiC7Tj7B24eOJux12Y+xD5xGFvbi8G+jzZHAflS+JdCge9uPIRQct2NXneq5C5/myI57CbmGP4VqX+YKsuDerXfDevRK5c5A3MRWntkbaHMiKoZZ2ah27nvm5pVRX0AyuzrHd4FxvyJ8wuFHW0V+v+2QUK0TauNinS8ftk1T7jahZg6sqz5SCX08SExGaQB+wjIi26I6uZ/WMIDgSBRlZ8Blf3wsFYd05XpXYx+Oag== 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=19bvCBJ/KZ5aY1D9uu5p27YI1kC7cS/eXe8kyDLZ23I=; b=SU49Wj9cKSRZxipX614MXeH+UQyq9kzV6DJH8a1YUTCZJPG0yJP6G4aMnUrtLKThaLc1Vp7/BcDzB4namtJ62TjW/wAnVC1oB5QvYtj8FEqaUXxtDA6i7rGwzTNPj6DKtMUeUnM+Ul3qoX8N6xppVmTnYhQmyPUuWpgqVxylnk3hYN85hFYDDSqsnoujAZf7zOz65++QyJNb7LykEMuQTzp1fd5AIijNwz3cWzB1NcOytVsjgG1s+Cno4xY/UrblT0OUytKkEuYUaKjFLI1JkVWluGljwgNXnXRtQxafbdtHl4hrbAJWYCMbylnk4hVKP/O734blYiJp/ZXjp9exjQ== 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=19bvCBJ/KZ5aY1D9uu5p27YI1kC7cS/eXe8kyDLZ23I=; b=eqQpqpEnTQ8r3d37gHg93JMCgyR8zPFeD1AnbNpeGMCHaOSFub3cUR+YbzBfFn8iOK4KYeyz58Fogow4BDsSaEu7Xg3KQC1DDwer/1kngg+rbjvhQupMninZfCVAdw6+axU1Ra4u0Gs6/dbpXB67tO0jDI2UmTeMPOTPrIitJRMbaG+pJiVjARC+RvcGt1aIpacjaqd9uEd7PnLLdlhy7PCKljEH3tMyXBQm+SgVt4c5mlf6abGNKOWWyypREtw9nhZn4GFKmMSJ5I4OTsCUOxTPa8s6LkHQQW8iRZxe5X6iv3lDGcmXuPA8Ge2WfxZgKRgqwM3TvNs+3ivMq2WmNQ== Received: from DB8EUR05FT045.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::41) by DB8EUR05HT015.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::457) 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:33:09 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc0f::46) by DB8EUR05FT045.mail.protection.outlook.com (2a01:111:e400:fc0f::383) 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:33:09 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:622FCA2CEA5DDC631B05538E78759147DD3FA699B6B6A941965555E4DDAECD62; UpperCasedChecksum:3A4E70CC13164BE21D807DDEB550971844BBE79B0D7B2CB19C301359BEB4CABF; SizeAsReceived:7592; Count:48 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:33:09 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 16 Jun 2021 01:31:54 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [apa56ULCUCRo1YVIBay4fn7BAlV2bXXW] 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-4-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:33:09 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: dce1ba1d-a013-45e0-eadf-08d93055ef37 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiR9SlwCHtPrt+MV8TUUwp4pWhkGqqrkWQJ/G2nBDhW1VuCUfUvgQwiH7rget1HUOjFrEum45Hm8dZ0aFhI7p6piV1lpH/NDEBzZyBRWyj/SwEkkD35CaBdMvE5GW1ybcLlPXzZsynvtmRTGJz+GrUXN3Jq1CH1DtQ81rK9Y8N9y+Bd/5QyuD0esyQq0/V45HdsNcXrBYr/1V027uBLbnaYauiqdB2xxBUCiN/4fMgnH+h/2uiguBzVvKSrnYdRo24LFuGEDDeL/bIgUjdyHQuL/w/2L7791CY4iZ07I27k7OZfQuYZiz82CYlgfZwk/SgqYKE/sZ9zmNLQ2sdOO+5R7FLsJLgeiS/bYtbK1gE6U361d/GE2HCvKovbVN7NV5Y2RNbQmasFb0HsvZD/DI0hSeyhjvHtU5sJiAJKaHE8Jc3EyekzF60YpLgy32kxM7Pkbq3SRCWjGrTTEqvDqTcy23s0f8X6I9cjTPAyyBybI+yuei4B6gRDt5sxFbMCl4A5YRqEsp5AdlQgFQUQDA4Y8aqPXmPPDtm528AkYvfEain7Z8hbn30ZyeY9gPga8tPx5AbwXHtFjsOC1UlNiTICB3Qwwd5scm3hZltaNTt0xDRCAYjxQJFWwGkkpOfsnTpyFY4IUVm0UHkPeO48zi9UL6McnhyvSx4MBBGpZnbpacfJI7xvmxHJcyic3ebRi4486ZmRWHViae9HOGIKL4Ijeh2sp1UKX5ZkxFRd0qWSOTIogxyCrLQj0jmBKDaoXugI= X-MS-TrafficTypeDiagnostic: DB8EUR05HT015: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 21hVsKacdYe+YP0jj4AmeeQRgvRP/hPh0BJgtARpYFPDQ2yIxPxpzeEHlO/KO2T4d0OF1WkRhZwldGsoqcZHrPP9T3R4dWivNGKr5qd9ZgPUsVpmCCOXxand9i5WgYQg1o6wbb/9Cigrt8QLZJDpHsh8vToEAFQWx0movO12kw1u1orWtaRlR3DAlIfmdfGOfNn3kzEGvapUZxSeSgckm61jzWxB6qNxL81AQrSD4zaDyK8TKlaUd9B/RkFM9vMZ4tXNzLYV5eVGZEGzI0MMQKqCxBi61iNr/blhzorxEz0Pix1RKBgM+WkbC3Sf1x9LfQXrQKno/X2xQmPHypVPP4aWcD7bsfh0cB3RQdqcAdIwwJqsn17GYdtmkrHPPxXIHsJ3Zgn6bKkr/PirI7kTdw== X-MS-Exchange-AntiSpam-MessageData: NedEpCnMpsDPWv3XuGGUdik2UT4Rwpg1MKli5OlymYDgGMoBHNc/i6cC94nHrGJzv9V0Suxo17QITcujqWgrM9O/4UuQ7aU2xvf6AM2qkgV+LdSb5Ire+jSEAJK83fI1wV7NX8kyqoAs+psYBkmE3w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dce1ba1d-a013-45e0-eadf-08d93055ef37 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2021 23:33:09.5847 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB8EUR05FT045.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: DB8EUR05HT015 Subject: [FFmpeg-devel] [PATCH 05/54] avformat/aaxdec: 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: gfftkoSlRZDk by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt --- libavformat/aaxdec.c | 83 ++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c index 0cbf933dfd..38d57d36c2 100644 --- a/libavformat/aaxdec.c +++ b/libavformat/aaxdec.c @@ -150,26 +150,20 @@ static int aax_read_header(AVFormatContext *s) return AVERROR(ENOMEM); a->xcolumns = av_calloc(a->columns, sizeof(*a->xcolumns)); - if (!a->xcolumns) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!a->xcolumns) + return AVERROR(ENOMEM); a->string_table = av_calloc(a->strings_size + 1, sizeof(*a->string_table)); - if (!a->string_table) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!a->string_table) + return AVERROR(ENOMEM); for (int c = 0; c < a->columns; c++) { uint8_t info = avio_r8(pb); uint32_t offset = avio_rb32(pb); int value_size; - if (offset >= a->strings_size) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (offset >= a->strings_size) + return AVERROR_INVALIDDATA; a->xcolumns[c].flag = info >> 4; a->xcolumns[c].type = info & 0x0F; @@ -196,8 +190,7 @@ static int aax_read_header(AVFormatContext *s) value_size = 0x10; break; default: - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } a->xcolumns[c].size = value_size; @@ -222,9 +215,8 @@ static int aax_read_header(AVFormatContext *s) ret = avio_read(pb, a->string_table, a->strings_size); if (ret != a->strings_size) { if (ret < 0) - goto fail; - ret = AVERROR(EIO); - goto fail; + return ret; + return AVERROR(EIO); } for (int c = 0; c < a->columns; c++) { @@ -244,10 +236,8 @@ static int aax_read_header(AVFormatContext *s) data_offset = a->schema_offset + col_offset; } else if (flag & COLUMN_FLAG_ROW) { data_offset = a->rows_offset + r * a->row_width + col_offset; - } else { - ret = AVERROR_INVALIDDATA; - goto fail; - } + } else + return AVERROR_INVALIDDATA; avio_seek(pb, data_offset, SEEK_SET); if (type == COLUMN_TYPE_VLDATA) { @@ -257,23 +247,17 @@ static int aax_read_header(AVFormatContext *s) size = avio_rb32(pb); a->segments[r].start = start + a->data_offset; a->segments[r].end = a->segments[r].start + size; - } else { - ret = AVERROR_INVALIDDATA; - goto fail; - } + } else + return AVERROR_INVALIDDATA; } } - if (!a->segments[0].end) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (!a->segments[0].end) + return AVERROR_INVALIDDATA; st = avformat_new_stream(s, NULL); - if (!st) { - ret = AVERROR(ENOMEM); - goto fail; - } + if (!st) + return AVERROR(ENOMEM); st->start_time = 0; par = s->streams[0]->codecpar; par->codec_type = AVMEDIA_TYPE_AUDIO; @@ -282,42 +266,28 @@ static int aax_read_header(AVFormatContext *s) if (!strcmp(codec, "AAX")) { par->codec_id = AV_CODEC_ID_ADPCM_ADX; avio_seek(pb, a->segments[0].start, SEEK_SET); - if (avio_rb16(pb) != 0x8000) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (avio_rb16(pb) != 0x8000) + return AVERROR_INVALIDDATA; extradata_size = avio_rb16(pb) + 4; - if (extradata_size < 12) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (extradata_size < 12) + return AVERROR_INVALIDDATA; avio_seek(pb, -4, SEEK_CUR); ret = ff_get_extradata(s, par, pb, extradata_size); - if (ret < 0) { - goto fail; - } + if (ret < 0) + return ret; par->channels = AV_RB8 (par->extradata + 7); par->sample_rate = AV_RB32(par->extradata + 8); - if (!par->channels || !par->sample_rate) { - ret = AVERROR_INVALIDDATA; - goto fail; - } + if (!par->channels || !par->sample_rate) + return AVERROR_INVALIDDATA; avpriv_set_pts_info(st, 64, 32, par->sample_rate); /*} else if (!strcmp(codec, "HCA") ){ par->codec_id = AV_CODEC_ID_HCA;*/ } else { - ret = AVERROR_INVALIDDATA; - goto fail; + return AVERROR_INVALIDDATA; } return 0; -fail: - av_freep(&a->string_table); - av_freep(&a->xcolumns); - av_freep(&a->segments); - - return ret; } static int aax_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -406,6 +376,7 @@ const AVInputFormat ff_aax_demuxer = { .name = "aax", .long_name = NULL_IF_CONFIG_SMALL("CRI AAX"), .priv_data_size = sizeof(AAXContext), + .flags_internal = FF_FMT_INIT_CLEANUP, .read_probe = aax_probe, .read_header = aax_read_header, .read_packet = aax_read_packet,