From bd71af24db441d8a64b86af15034cf97bcf2204b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 27 Feb 2019 13:42:00 +0100 Subject: [PATCH] Fix some minor things found looking at Valgrind output --- Common/FileUtil.cpp | 2 +- Core/Dialog/PSPMsgDialog.cpp | 2 +- Core/HLE/sceMpeg.cpp | 8 +++++--- Core/Util/PPGeDraw.cpp | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index 5ca7b0f1b9..69504428eb 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -830,7 +830,7 @@ const std::string &GetExeDirectory() uint32_t program_path_size = sizeof(program_path) - 1; #if defined(__linux__) - if (readlink("/proc/self/exe", program_path, 4095) > 0) + if (readlink("/proc/self/exe", program_path, program_path_size) > 0) #elif defined(__APPLE__) && !defined(IOS) if (_NSGetExecutablePath(program_path, &program_path_size) == 0) #elif defined(KERN_PROC_PATHNAME) diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index 302113b3b5..ca9e283f3e 100755 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -146,7 +146,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK) float WRAP_WIDTH = 300.0f; if (UTF8StringNonASCIICount(text.c_str()) > 3) WRAP_WIDTH = 372.0f; - + float y = 140.0f; float h, sy ,ey; int n; diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index a76a216fa4..43f30b9ce6 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -318,12 +318,12 @@ static void AnalyzeMpeg(u8 *buffer, u32 validSize, MpegContext *ctx) { ctx->audioFrameCount = 0; ctx->endOfAudioReached = false; ctx->endOfVideoReached = false; - + // Sanity Check ctx->mpegFirstTimestamp if (ctx->mpegFirstTimestamp != 90000) { WARN_LOG_REPORT(ME, "Unexpected mpeg first timestamp: %llx / %lld", ctx->mpegFirstTimestamp, ctx->mpegFirstTimestamp); } - + if (ctx->mpegMagic != PSMF_MAGIC || ctx->mpegVersion < 0 || (ctx->mpegOffset & 2047) != 0 || ctx->mpegOffset == 0) { // mpeg header is invalid! @@ -511,7 +511,7 @@ static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr Memory::Write_U32(ringbufferAddr, mpegHandle + 16); Memory::Write_U32(ringbuffer->dataUpperBound, mpegHandle + 20); } - MpegContext *ctx = new MpegContext; + MpegContext *ctx = new MpegContext(); if (mpegMap.find(mpegHandle) != mpegMap.end()) { WARN_LOG_REPORT(HLE, "Replacing existing mpeg context at %08x", mpegAddr); // Otherwise, it would leak. @@ -532,6 +532,8 @@ static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr ctx->ignorePcm = false; ctx->ignoreAvc = false; ctx->defaultFrameWidth = frameWidth; + ctx->mpegStreamSize = 0; + ctx->mpegOffset = 0; for (int i = 0; i < MPEG_DATA_ES_BUFFERS; i++) { ctx->esBuffers[i] = false; } diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 74dc3baa8d..d0bd9ae4c7 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -477,7 +477,7 @@ static AtlasTextMetrics BreakLines(const char *text, const AtlasFont &atlasfont, utfWord = utfPrev; finished = true; break; - } + } } } ++numChars; @@ -549,7 +549,7 @@ static AtlasTextMetrics BreakLines(const char *text, const AtlasFont &atlasfont, } lineWidth += nextWidth; - u32 cval = utf.next(); + u32 cval = utf.end() ? 0 : utf.next(); if (spaceWidth > 0) { if (!dryRun)