X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fppf.c;h=f6ccfca7e8101a7be8af7a11d952c2c469b5c9a3;hb=a0cffa0ffa785fbaff1c563627d6ce9dc0523287;hp=6fcd5bc1094f837dd4eba1a87c5b417800da21f1;hpb=4e44d6f63e9f1af3236fbbe2f59016cd42a67d98;p=pcsx_rearmed.git diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index 6fcd5bc1..f6ccfca7 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -183,7 +183,7 @@ void BuildPPFCache() { char method, undo = 0, blockcheck = 0; int dizlen, dizyn; unsigned char ppfmem[512]; - char szPPF[MAXPATHLEN]; + char szPPF[MAXPATHLEN * 2]; int count, seekpos, pos; u32 anz; // use 32-bit to avoid stupid overflows s32 ladr, off, anx; @@ -339,7 +339,7 @@ unsigned char *sbi_sectors; int LoadSBI(const char *fname, int sector_count) { char buffer[16]; FILE *sbihandle; - u8 sbitime[3]; + u8 sbitime[3], t; int s; sbihandle = fopen(fname, "rb"); @@ -347,14 +347,29 @@ int LoadSBI(const char *fname, int sector_count) { return -1; sbi_sectors = calloc(1, sector_count / 8); - if (sbi_sectors == NULL) + if (sbi_sectors == NULL) { + fclose(sbihandle); return -1; + } // 4-byte SBI header fread(buffer, 1, 4, sbihandle); - while (!feof(sbihandle)) { - fread(sbitime, 1, 3, sbihandle); - fread(buffer, 1, 11, sbihandle); + while (1) { + s = fread(sbitime, 1, 3, sbihandle); + if (s != 3) + break; + fread(&t, 1, 1, sbihandle); + switch (t) { + default: + case 1: + s = 10; + break; + case 2: + case 3: + s = 3; + break; + } + fseek(sbihandle, s, SEEK_CUR); s = MSF2SECT(btoi(sbitime[0]), btoi(sbitime[1]), btoi(sbitime[2])); if (s < sector_count)