(MESS) pce_slot.c: fixed crash when loading images smaller than 256K

(unfortunately this was happening only randomly on MacOSX, so I was
never able to find the culprit until recent MT reports). nw.
This commit is contained in:
Fabio Priuli 2014-10-14 20:08:33 +00:00
parent 54fe1343cf
commit 2e451cdf36

View File

@ -309,11 +309,11 @@ int pce_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
type = PCE_POPULOUS;
// Check for CD system card v3 which adds on-cart RAM to the system
if (!memcmp(ROM + 0x3FFB6, "PC Engine CD-ROM SYSTEM", 23))
if (len >= 0x3ffb6 + 23 && !memcmp(ROM + 0x3ffb6, "PC Engine CD-ROM SYSTEM", 23))
{
/* Check if 192KB additional system card ram should be used */
if(!memcmp(ROM + 0x29D1, "VER. 3.", 7)) { type = PCE_CDSYS3J; } // JP version
else if(!memcmp(ROM + 0x29C4, "VER. 3.", 7 )) { type = PCE_CDSYS3U; } // US version
if (!memcmp(ROM + 0x29d1, "VER. 3.", 7)) { type = PCE_CDSYS3J; } // JP version
else if (!memcmp(ROM + 0x29c4, "VER. 3.", 7 )) { type = PCE_CDSYS3U; } // US version
}
return type;