From 7741376a3822370cd9ea8fab3cffcffe6266c034 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 5 May 2013 21:29:41 -0700 Subject: [PATCH] Check a potential crash in sceFontOpen(). --- Core/HLE/sceFont.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 4201f8bce9..f0fdea1eff 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -605,13 +605,18 @@ int sceFontDoneLib(u32 fontLibHandle) { // Open internal font into a FontLib u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr) { - INFO_LOG(HLE, "sceFontOpen(%x, %x, %x, %x)", libHandle, index, mode, errorCodePtr); if (!Memory::IsValidAddress(errorCodePtr)) { - Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); + // Would crash on the PSP. + ERROR_LOG(HLE, "sceFontOpen(%x, %x, %x, %x): invalid pointer", libHandle, index, mode, errorCodePtr); return 0; } + INFO_LOG(HLE, "sceFontOpen(%x, %x, %x, %x)", libHandle, index, mode, errorCodePtr); FontLib *fontLib = GetFontLib(libHandle); + if (fontLib == NULL) { + Memory::Write_U32(ERROR_FONT_INVALID_LIBID, errorCodePtr); + return 0; + } if (index >= internalFonts.size()) { Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); return 0;