diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 679790fd2..6f6877ec0 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1044,11 +1044,14 @@ u32 sceMpegRingbufferPut(u32 ringbufferAddr, u32 numPackets, u32 available) return 0; } + numPackets = std::min(numPackets, available); + if (numPackets <= 0) { + ERROR_LOG(HLE, "zero or sub-zero number of packets put"); + return 0; + } SceMpegRingBuffer ringbuffer; Memory::ReadStruct(ringbufferAddr, &ringbuffer); - numPackets = std::min(numPackets, available); - MpegContext *ctx = getMpegCtx(ringbuffer.mpeg); if (!ctx) { WARN_LOG(HLE, "sceMpegRingbufferPut(%08x, %i, %i): bad mpeg handle %08x", ringbufferAddr, numPackets, available, ringbuffer.mpeg);