From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D1F414B04B for ; Sun, 26 May 2024 23:53:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E17268D504; Mon, 27 May 2024 02:52:44 +0300 (EEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CAB6C68D4F6 for ; Mon, 27 May 2024 02:52:35 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2EB04240004 for ; Sun, 26 May 2024 23:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1716767555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HGqEOMTsFMUAPHUj6eChjqMt2x36GtH4JJ9IAgKgg1A=; b=eHPknPiwjSuNHWFnFH5EnuGQbHkqUfUO3CbyVYZ/eZqepm/NPhHbcjiJxygfkB+kKS9U/P SW/yzmAs6CMQR0kEVBcQ5lJr3ckE4N3KJg9RZgjFjkvYMljUFcXLwBiOWEL2neG99d0AKG lUikzcXwjG+bqY6UjEru4FBc82e5cJ3vaGUNowTDPpnbVKJYa7gc/SuciDtQxWl8PRnLk5 9h1f0KSYgyBVNb9sl697yOjV+Cx6JohxEv/y8yxcJVCg0cXoCwJh9p8y6AM3/5vHkclUai B7inMWLm/pbz2+WL+uSJAtsE1rXxby/I9XBnx+N+AnwSslU0MB3DuYEFDDyMjg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 27 May 2024 01:52:17 +0200 Message-ID: <20240526235230.2876318-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240526235230.2876318-1-michael@niedermayer.cc> References: <20240526235230.2876318-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 05/17] avcodec/dxva2_*: Initialize dxva_data_ptr 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fixes: CID1591888 Uninitialized scalar variable Fixes: CID1591925 Uninitialized pointer read Fixes: CID1591933 Uninitialized scalar variable Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/dxva2_av1.c | 4 ++-- libavcodec/dxva2_hevc.c | 5 ++++- libavcodec/dxva2_mpeg2.c | 5 ++++- libavcodec/dxva2_vc1.c | 5 ++++- libavcodec/dxva2_vp9.c | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c index 1b555106599..ea97fcb87e5 100644 --- a/libavcodec/dxva2_av1.c +++ b/libavcodec/dxva2_av1.c @@ -354,7 +354,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const AV1DecContext *h = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data; unsigned dxva_size; unsigned padding; @@ -382,7 +382,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, dxva_data = dxva_data_ptr; - if (ctx_pic->bitstream_size > dxva_size) { + if (!dxva_data || ctx_pic->bitstream_size > dxva_size) { av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer"); return -1; } diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 31d74a7164d..5eb166c3075 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -248,7 +248,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const HEVCFrame *current_picture = h->ref; struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; DXVA_Slice_HEVC_Short *slice = NULL; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; void *slice_data; @@ -278,6 +278,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, } #endif + if (!dxva_data_ptr) + return -1; + dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index d31a8bb8724..5de062e5308 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -160,7 +160,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, s->current_picture_ptr->hwaccel_picture_private; const int is_field = s->picture_structure != PICT_FRAME; const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; unsigned i; @@ -186,6 +186,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, } #endif + if (!dxva_data_ptr) + return -1; + dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index f7513b2b153..04f26ddff66 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -197,7 +197,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0; const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode); DXVA_SliceInfo *slice = NULL; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; unsigned padding; @@ -224,6 +224,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, } #endif + if (!dxva_data_ptr) + return -1; + dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; diff --git a/libavcodec/dxva2_vp9.c b/libavcodec/dxva2_vp9.c index ca8b3b136da..f4ab91c580b 100644 --- a/libavcodec/dxva2_vp9.c +++ b/libavcodec/dxva2_vp9.c @@ -172,7 +172,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const VP9SharedContext *h = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data; unsigned dxva_size; unsigned padding; @@ -200,7 +200,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, dxva_data = dxva_data_ptr; - if (ctx_pic->slice.SliceBytesInBuffer > dxva_size) { + if (!dxva_data || ctx_pic->slice.SliceBytesInBuffer > dxva_size) { av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream"); return -1; } -- 2.45.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".