Check a potential crash in sceFontOpen().

This commit is contained in:
Unknown W. Brackets 2013-05-05 21:29:41 -07:00
parent f9e4739c64
commit 7741376a38

View File

@ -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;