From 709c9dc93cd5148dc23ee4e701371ab310eab0a0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 23 Apr 2019 19:48:01 -0700 Subject: [PATCH] Mp3: Fix errors on sceMp3NotifyAddStreamData. --- Core/HLE/sceMp3.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceMp3.cpp b/Core/HLE/sceMp3.cpp index dfa8e6337d..b53b6f1d2d 100644 --- a/Core/HLE/sceMp3.cpp +++ b/Core/HLE/sceMp3.cpp @@ -495,15 +495,16 @@ static int sceMp3GetInfoToAddStreamData(u32 mp3, u32 dstPtr, u32 towritePtr, u32 } static int sceMp3NotifyAddStreamData(u32 mp3, int size) { - DEBUG_LOG(ME, "sceMp3NotifyAddStreamData(%08X, %i)", mp3, size); - AuCtx *ctx = getMp3Ctx(mp3); if (!ctx) { - ERROR_LOG(ME, "%s: bad mp3 handle %08x", __FUNCTION__, mp3); - return -1; + if (mp3 >= MP3_MAX_HANDLES) + return hleLogError(ME, ERROR_MP3_INVALID_HANDLE, "invalid handle"); + return hleLogError(ME, ERROR_MP3_UNRESERVED_HANDLE, "unreserved handle"); + } else if (ctx->AuBuf == 0) { + return hleLogError(ME, ERROR_MP3_UNRESERVED_HANDLE, "incorrect handle type"); } - return ctx->AuNotifyAddStreamData(size); + return hleLogSuccessI(ME, ctx->AuNotifyAddStreamData(size)); } static int sceMp3ReleaseMp3Handle(u32 mp3) {