X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fppf.c;h=f37687cc007a7dae10f5aa47ad73738495078a3e;hp=a7f6aefd4d16e62f0c01f4b1adb66116a6069e50;hb=f3746eea2d69d08948522600b99388618ec46f1b;hpb=76c06a1a8a2c359341a086c87c9a12c9926c440f diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index a7f6aefd..f37687cc 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -357,6 +357,7 @@ fail_io: // redump.org SBI files, slightly different handling from PCSX-Reloaded unsigned char *sbi_sectors; +int sbi_len; int LoadSBI(const char *fname, int sector_count) { int good_sectors = 0; @@ -370,7 +371,8 @@ int LoadSBI(const char *fname, int sector_count) { if (sbihandle == NULL) return -1; - sbi_sectors = calloc(1, sector_count / 8); + sbi_len = (sector_count + 7) / 8; + sbi_sectors = calloc(1, sbi_len); if (sbi_sectors == NULL) goto end; @@ -414,15 +416,13 @@ int LoadSBI(const char *fname, int sector_count) { break; } - fclose(sbihandle); - return 0; - end: if (!clean_eof) SysPrintf(_("SBI: parse failure at 0x%lx\n"), ftell(sbihandle)); if (!good_sectors) { free(sbi_sectors); sbi_sectors = NULL; + sbi_len = 0; } fclose(sbihandle); return sbi_sectors ? 0 : -1; @@ -432,5 +432,6 @@ void UnloadSBI(void) { if (sbi_sectors) { free(sbi_sectors); sbi_sectors = NULL; + sbi_len = 0; } }