#include "psxcommon.h"
#include "ppf.h"
+#include "misc.h"
#include "cdrom.h"
typedef struct tagPPF_DATA {
if (iPPFNum <= 0) return;
pc = ppfCache = (PPF_CACHE *)malloc(iPPFNum * sizeof(PPF_CACHE));
+ if (pc == NULL) return;
iPPFNum--;
p = ppfHead;
static void AddToPPF(s32 ladr, s32 pos, s32 anz, unsigned char *ppfmem) {
if (ppfHead == NULL) {
ppfHead = (PPF_DATA *)malloc(sizeof(PPF_DATA) + anz);
+ if (ppfHead == NULL) return;
ppfHead->addr = ladr;
ppfHead->pNext = NULL;
ppfHead->pos = pos;
}
padd = (PPF_DATA *)malloc(sizeof(PPF_DATA) + anz);
+ if (padd == NULL) return;
padd->addr = ladr;
padd->pNext = p;
padd->pos = pos;
// 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;
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;
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;
if (sbi_sectors) {
free(sbi_sectors);
sbi_sectors = NULL;
+ sbi_len = 0;
}
}