From 07e61d8dcf16099a862baee79b4ec1e06d76b3d4 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 11 Aug 2011 14:40:39 +0000 Subject: [PATCH] Fix crashing on certain files with no filename extension. --- src/file.cpp | 10 +++++++++- src/jaguar.cpp | 3 +++ src/joystick.cpp | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 4b389e6..22f3c8f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -186,7 +186,7 @@ bool JaguarLoadFile(char * path) // // "Alpine" file loading // Since the developers were coming after us with torches and pitchforks, we decided to -// allow this kind of thing. ;-) But ONLY FOR THE DEVS, DAMMIT! O_O +// allow this kind of thing. ;-) But ONLY FOR THE DEVS, DAMMIT! >:-U O_O // bool AlpineLoadFile(char * path) { @@ -252,7 +252,15 @@ static int gzfilelength(gzFile gd) // static bool CheckExtension(const char * filename, const char * ext) { + // Sanity checking... + if ((filename == NULL) || (ext == NULL)) + return false; + const char * filenameExt = strrchr(filename, '.'); // Get the file's extension (if any) + + if (filenameExt == NULL) + return false; + return (strcasecmp(filenameExt, ext) == 0 ? true : false); } diff --git a/src/jaguar.cpp b/src/jaguar.cpp index 2cf99db..aecebd3 100644 --- a/src/jaguar.cpp +++ b/src/jaguar.cpp @@ -1747,6 +1747,9 @@ void JaguarDone(void) JaguarDasm(0x89CA56, 0x200); WriteLog("-------------------------------------------\n"); JaguarDasm(0x802B48, 0x200); + WriteLog("\n\nM68000 disassembly at $802000...\n"); + JaguarDasm(0x802000, 6000); + WriteLog("\n");//*/ #endif } diff --git a/src/joystick.cpp b/src/joystick.cpp index 146c15d..66be330 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -341,7 +341,10 @@ uint8 JoystickReadByte(uint32 offset) // This is bad--we're assuming that a bit is set in the last case. Might not be so! // NOTE: values $7, B, D, & E are only legal ones for pad 0, (rows 3 to 0, in both cases) // $E, D, B, & 7 are only legal ones for pad 1 -// So the following code is WRONG! +// So the following code is WRONG! (now fixed! ;-) +// Also: we should explicitly check for those bit patterns, as other patterns +// are legal and yield other controllers... !!! FIX !!! +#warning "!!! Need to explicitly check for the proper bit combinations! !!!" if (!(pad0Index & 0x01)) pad0Index = 0; -- 2.37.2