From 30bb6c9fb958df622aeef71df229c69a583a246a Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 19 Apr 2024 23:47:50 +0200 Subject: [PATCH] cellSysutilAvc2MicRead: Fix some nonsensical nullptr deref warning --- rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp b/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp index 44ef450675..de617447ee 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp @@ -523,10 +523,11 @@ error_code cellSysutilAvc2MicRead(vm::ptr ptr, vm::ptr pSize) // TODO: ringbuffer (holds 100ms of 16kHz single channel f32 samples) std::vector buf{}; - const u32 size_read = std::min(*pSize, ::size32(buf)); + u32 size_read = 0; - if (size_read > 0) + if (u32 size_to_read = *pSize; size_to_read > 0 && !buf.empty()) { + size_read = std::min(size_to_read, ::size32(buf)); std::memcpy(ptr.get_ptr(), buf.data(), size_read); }