From patchwork Tue Nov 14 18:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rogozhkin, Dmitry V" X-Patchwork-Id: 44664 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp2174468pzg; Tue, 14 Nov 2023 10:23:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5K0zV3uWh23iBd9C1/Trev9M6ttqcmce56/MpvY1O1vbxXOcOr0PI9q8n03HIUy7eNG4g X-Received: by 2002:a05:6402:268c:b0:53f:72a7:5ae with SMTP id w12-20020a056402268c00b0053f72a705aemr8860678edd.12.1699986225250; Tue, 14 Nov 2023 10:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699986225; cv=none; d=google.com; s=arc-20160816; b=xnn5msAbPsXjCIryxPIGzncC1J8CP+LoiQxNMudLKHu+O2crtSGhengqnE7ORYgAQI KOkPcMoWlPTWXivtoOZx6pql+Tmhwit/O8jhzfdtb8QvhLqlWN8xZzyd6dInurr/fMON FYfeGVo6qXP+sH7q/otFcLsgExTHHwliV/pV5xcFaLOIKAlBYLjQnQgrY4AIMR/zG7nK SFUwuowEUNuCiQLXea3v21Q6jxwhSXGSjWBfHoRAYUN6AmdlcIIpsJnpCFs9Eti+KvYi WBE1m4uaUBK65mtRyh8WeBVddH6sQlNKtfK/rm7FADcJLIWc5mZPzH8cebL7VSr6VAhN rq2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to; bh=+BJGGQwCAlWcpXhNEnqtlmtMvtkt4H+UUjKElyw/sbE=; fh=z34nsZay6HvjYIRPk5BwyArNH+rsauucRUMCMjMxepw=; b=YW124hIqIGGoXc9zE+beAU21UjgCb4e/93dAIo6SxsX8LYren0W7poGvrb7neJs9+M Bs7QqxdZ/gRUAQtAxoQW4k2JpSKZ2rL1DHvmEhc1+ZYCXPcnQ0CY1PuXMBQcmNYw26Th 5j2lEdvp3vvjex3IAnleaAadY2bzVhXlu/3EeNoOgqzuOAABG8jIwSHft6tTpIrbFD1G OtU/0zx9RQBKmvIK7orQzsBLTQcLhny0huG2iKDs8rINSY2bdHa95MkVIaPWRh4UAL9I bRh28IVXLoYOqL3O+iqmGCYLW3uxlcCspeRHrrCBrrU/4mBgEDnGw5UnaAzIecVXLPj8 dmiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=YP5a6WtY; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c11-20020a05640227cb00b005413b1d8d61si4360767ede.392.2023.11.14.10.23.22; Tue, 14 Nov 2023 10:23:45 -0800 (PST) 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=@intel.com header.s=Intel header.b=YP5a6WtY; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0ABCE68CD3A; Tue, 14 Nov 2023 20:23:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02BA168C8A5 for ; Tue, 14 Nov 2023 20:23:10 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699986196; x=1731522196; h=from:to:cc:subject:date:message-id; bh=CoyNJo4g1slY7hqsZjimHwBQU85aExRZ91kl7xZ2IME=; b=YP5a6WtYJv3PeWbj1Ca7wQgHQkY/lRTknniMM7wd4ozGG52as7KBUPp9 UNNTcp+0onS/Yxj7HM2q4fhMUQ8INODYlYdOpqXsn3lQJ1KF1IV3xuFR3 gE9QkqEdkkHZ7gy5PvGEeXa0Td0OlvRYYjd5zGitiTDHTdg788mzgX/v7 9fPdvqGzp3jC95JkG5fqLrb/TjnB3c63WWA9CM4r4GbXD2DA6DJ6ann5C tg6qgIOxBNK1vLMIL9P++gZ7/zRsJPlUFioZnHnLNl68bpX1lEJEcExSE 5d1zP8L2k5ohnZIw1vGUp7y/gSGXYhl8WXOPgY1jviEfcj4rnyqWVokcF Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="3826678" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="3826678" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 10:23:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="714638377" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="714638377" Received: from dvrscl.jf.intel.com ([10.54.72.26]) by orsmga003.jf.intel.com with ESMTP; 14 Nov 2023 10:23:07 -0800 From: Dmitry Rogozhkin To: ffmpeg-devel@ffmpeg.org Date: Tue, 14 Nov 2023 10:22:31 -0800 Message-Id: <1699986151-24741-1-git-send-email-dmitry.v.rogozhkin@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH] avcodec/decode: guard against NULL hw_frames_ctx 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: Christoph Reiter , Dmitry Rogozhkin , Lynne MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: scRvtl/WXaiI Gurd against segfault running VLC decoding under msys2 [1]: Thread 33 received signal SIGSEGV, Segmentation fault. [Switching to Thread 37728.0xadd0] ff_hwaccel_frame_priv_alloc (avctx=0x6447b00, hwaccel_picture_private=0x65dfd00) at libavcodec/decode.c:1848 1848 frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; (gdb) bt at libavcodec/decode.c:1848 at libavcodec/h264_slice.c:208 first_slice=1) at libavcodec/h264_slice.c:1599 at libavcodec/h264_slice.c:2130 at libavcodec/h264dec.c:652 got_frame=0x646e4b0, avpkt=0x64522c0) at libavcodec/h264dec.c:1048 (gdb) p avctx $1 = (AVCodecContext *) 0x6447b00 (gdb) p avctx->hw_frames_ctx $2 = (AVBufferRef *) 0x0 See[1]: https://github.com/msys2/MINGW-packages/pull/19050 Fixes: be07145109 ("avcodec: add AVHWAccel.free_frame_priv callback") CC: Lynne CC: Christoph Reiter Signed-off-by: Dmitry Rogozhkin --- libavcodec/decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index ad39021..3caaeec 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1845,9 +1845,9 @@ int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_pr av_assert0(!*hwaccel_picture_private); - frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; + frames_ctx = (AVHWFramesContext *) avctx->hw_frames_ctx ? avctx->hw_frames_ctx->data : NULL; *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0, - frames_ctx->device_ctx, + frames_ctx ? frames_ctx->device_ctx : NULL, hwaccel->free_frame_priv); if (!*hwaccel_picture_private) return AVERROR(ENOMEM);