From 88ee62be26392e31721586a52ca3702c671b0daa Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 25 May 2022 11:40:51 +0200 Subject: [PATCH] cellAdec: fix uninitialized default size of AVPacketHolder (#12077) --- rpcs3/Emu/Cell/Modules/cellAdec.cpp | 12 ++++++------ rpcs3/util/media_utils.cpp | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAdec.cpp b/rpcs3/Emu/Cell/Modules/cellAdec.cpp index 9fc4f57196..8962e70086 100644 --- a/rpcs3/Emu/Cell/Modules/cellAdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAdec.cpp @@ -456,19 +456,19 @@ public: struct AVPacketHolder : AVPacket { - AVPacketHolder(u32 size) + AVPacketHolder(u32 data_size) { av_init_packet(this); - if (size) + if (data_size) { - data = static_cast(av_calloc(1, size + AV_INPUT_BUFFER_PADDING_SIZE)); - this->size = size + AV_INPUT_BUFFER_PADDING_SIZE; + this->data = static_cast(av_calloc(1, data_size + AV_INPUT_BUFFER_PADDING_SIZE)); + this->size = data_size + AV_INPUT_BUFFER_PADDING_SIZE; } else { - data = nullptr; - size = 0; + this->data = nullptr; + this->size = 0; } } diff --git a/rpcs3/util/media_utils.cpp b/rpcs3/util/media_utils.cpp index fde01871f7..1fb20e0620 100644 --- a/rpcs3/util/media_utils.cpp +++ b/rpcs3/util/media_utils.cpp @@ -324,8 +324,6 @@ namespace utils } // Prepare to read data - AVPacket packet; - av_init_packet(&packet); av.frame = av_frame_alloc(); if (!av.frame) { @@ -335,6 +333,9 @@ namespace utils } duration_ms = stream->duration / 1000; + + AVPacket packet{}; + av_init_packet(&packet); // Iterate through frames while (thread_ctrl::state() != thread_state::aborting && av_read_frame(av.format, &packet) >= 0)