From patchwork Tue Mar 30 22:26:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26666 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 BE281449CBB for ; Wed, 31 Mar 2021 01:26:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F1B468A141; Wed, 31 Mar 2021 01:26:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074055.outbound.protection.outlook.com [40.92.74.55]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3BAB6687FEC for ; Wed, 31 Mar 2021 01:26:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ih6AUeeJE1aAEfOgWtqUNG1QceYe49D3+SUe0nSiQo8c0WFqW2Sr68x66dUbz9S4XjLuWwlBe8pzvxR5D5/Aq7Prlo7Bfm6d1amgI3B6Nz0436i0jXBHyQrzL3guu7fDzVJsP/swgs8lBe3i6HPoeP5DJ255V0n3ztD9dD4mGyC1ekBrCPhs5RSGA3dFdV0C0enHedWt+5VQtiDWUGVp42yFsdYW2bFMhHsMzTz43mPGVtfBlsv9nefOwRvM1Ajey51sVSuzmf//EWEqe/CaKJRXLz0FYPDthxGI46VFnjWtCIREWeS1l56Y1Ebr8919IfXuU8KHEIUSQxiKcLRkZA== 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=sGTgGnfUTozModnHLwVF0OmgXbujizTzfjxZfsl0mOc=; b=oYaSIWxi6Qo1hVWdDPexADVKzT4+rxwokOS/mLY1OWeJsFEJimJCQqwG5Nomn0yzNJASi4QnZVrg2/1K9Lv06oEQMOwBoAD4Y6LPgeDEf0oVUmSUUW+XaQqeA2FITyuw0b+BLpfgPAp+fhfRIQaNBhA5kWPAgOebAfFtHVqPF/wmqEMtXW/rcbdLWISGalcwuh6iadGopR5TVosLgDNxLfvuafBRodwxCRtCQKpXp0dvXdKEN9p5yL0xeyueK3ofkg6hFDucNSYbUrz9m6MLyf/NRXePnNIq3tC55h6Xd7PpGbDsnTbm/GHWpU+zBXnYxFqkUDdcXe7uKgVD1rrdEQ== 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=sGTgGnfUTozModnHLwVF0OmgXbujizTzfjxZfsl0mOc=; b=J+3D8d6MNe5uU5SWfBkjPe0XF1ktqMmuq81OPgxldQ7+vSfjEn6OQnaIB2XbPuhIR3i40P6e6X9Rk2Y0oqm0TXjDhp+R4yi2PMro23vr1hR0NAJa9f6l0mHyRJmlky8j+FkEFS71A34/mqc/gsQc1twmIdzfyMOoWzn8OPRgoA1+RYCwaiFZFO7bqrk0ZSsBENaj40f+vMaQPWubBwEubeut5PybUOcTPBnqUu4xZnlGPy203+iNPMneDG2Li98RY2VE/Xn6cA/6Qj+NVqlXN1J6A4jp8WcwYVJCKg2dKzJjDM/IGqnYXRVS0C0L91JUSrnRwatyiIQObJFDO9GoxQ== Received: from HE1EUR04FT039.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::4b) by HE1EUR04HT154.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Tue, 30 Mar 2021 22:26:37 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::51) by HE1EUR04FT039.mail.protection.outlook.com (2a01:111:e400:7e0d::153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29 via Frontend Transport; Tue, 30 Mar 2021 22:26:37 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4155E4002E178CA32087EA1F83CACA4F1EB897059C2E3B4766D2DDC9AD60EEE8; UpperCasedChecksum:54EC4CF8831C8975F1BE63D77D19778E20E733CE0DFDB3F3B03CFA7B162D3072; SizeAsReceived:7372; Count:45 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21%3]) with mapi id 15.20.3977.033; Tue, 30 Mar 2021 22:26:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Mar 2021 00:26:24 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 X-TMN: [FYRugA5iH0+3h7LaRQDAntoZc38LFueO] X-ClientProxiedBy: AM0PR10CA0021.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::31) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210330222624.1122271-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.137.96) by AM0PR10CA0021.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Tue, 30 Mar 2021 22:26:36 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 45 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 78b8d9fe-cfe1-41a2-1e57-08d8f3cae181 X-MS-Exchange-SLBlob-MailProps: tBYDyRQCPcntoCyaKijSyt42l9wfk8+8IfcEvx/cmcZshVYhNpAtbruS/+5aJvGXydeLr2f2jM8GAeKaaJZHwAnyrbI52zSPh52N7F/kGzmSggNKg3PueBsEeGM0WOOnHG2MXRIwow8f+zj7O1uXS6CbdPw0gG62Lg6Rr1d1PlEoW0SjX0kt+TSiaeZcyHo2RlEyvwyhm5p9l4m3MhMgzd4rVRmE5exQnnVmzDASc1Ta/v3lVAm3ZDUMGZC7ACOPJ4zXZxLRtKwbIqZ4oP+m17X8Pz5eGRbMLPksbQsr2RQJ+Msz74uihaqXOpUsqUh4XTpzqhxiB2O4IkiIja9OxdK8YqzgwIEZJYy4NNKZBlGafwm2y1HtJvIIWo1vjiowP0JOv0hb2fcr932KIRVGIgr+aNqEQGA6/UjGkQTO7q8o0ku3szexY0CDdUArM67iv2uccEgNcvXLSnWKBH/11h6zIAZICnHU1h5ZzKDodZSZGL25EjuWDf9Au8qIMbIX8jC4yHbiyvwTrUBmC8LEYjtgRsHv8MYHns+13DB8Pz9s8T4wUoP5BnHYWFgtQPxJLNaE7QneA0iXPQ9E0yOgdo2TDWGp6dxqesNLVSJMfOE7LLedR8fqopQn7beRu21rn/F352fv4uQEKfv+OF2vz+LpBIX7me3ixFOwQAyX5Cxggo5MszHckUpbXskR0ZkujGQI19GYBrET71N7XhWwW1ioDnr2dIJFvaKY+qujI2M1u6+8NvHWQxpvhKT0S0otzMhFcvIx7YE= X-MS-TrafficTypeDiagnostic: HE1EUR04HT154: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wUe3vWGztTMImDvj0JDZmtGLGFnSHX9pjgbk0n+n1vl2DDrGVNKdQsLSRTBFH3x40XVHeDFHNpvG0jwUXFt6liH47YLJhrKj1fgxlRIcaB9yhNW6D2X1gTlMWKNjLSb9Hd1s6j3KJCRzcsPpyC8xi0hJkrl7bX2h/X/4qSmMkyvBv2fNhHa+WxVeiRXCpHd61O6AV1OzEYkTJaWXDJswgoK5poaoaKhR8lfZDBih2xLWbmsOEkeOwfeWH7/QU49qjVPTrzpd6s3n9G4I3DmjGfd/NBVsb9zuPQCmYWoJoAwTRUcEyd7g2ZKCoyRNgOSPOQ2u/aiq3fiN4k6tnMlDkPHMbadun1fO0QJ8a29FwIc9x5d2fb2ISSiYRKEoAcZX+fd7MXANi8KGHxX5w1pvLA== X-MS-Exchange-AntiSpam-MessageData: UZ1ay0bqnYvmq9H9YRrIIaZQt77OfRGmRTuNZSFRmS/Vtkt3aq4L827n2BB+m+LY8mn7fN9XRguVAx7sVhZeYTEe92VKniY1qw8NX/GQBVs76Oq1JRIWz2piJMHqOhircwkbdNPpeWFn2kOf3AUeYQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78b8d9fe-cfe1-41a2-1e57-08d8f3cae181 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 22:26:36.7632 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT039.eop-eur04.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: HE1EUR04HT154 Subject: [FFmpeg-devel] [PATCH] avcodec/mjpegenc: Fix segfault when freeing incomplete context 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" When allocating the MJpegContext fails (or if the dimensions run afoul of the 65500x65500 limit), an attempt to free a subbuffer of said context leads to a segfault in ff_mjpeg_encode_close(). Seems to be a regression since 467d9e27e0cb2bf74f41dc832f2f8d191ba58ec9. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index df3aaaf26b..596b7544ca 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -312,8 +312,10 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s) av_cold void ff_mjpeg_encode_close(MpegEncContext *s) { - av_freep(&s->mjpeg_ctx->huff_buffer); - av_freep(&s->mjpeg_ctx); + if (s->mjpeg_ctx) { + av_freep(&s->mjpeg_ctx->huff_buffer); + av_freep(&s->mjpeg_ctx); + } } /**