pointed out by gcc analyzer
-Subproject commit 7167e5f3376f0d0692ae102ed2df1ef5d2cc199a
+Subproject commit 5dd225ecd6d5a04fd8e6f16c8f8ee65ee88c6fed
static void SignalExit(int sig) {
// only to restore framebuffer/resolution on some devices
plat_finish();
static void SignalExit(int sig) {
// only to restore framebuffer/resolution on some devices
plat_finish();
- Cheats[NumCheats].Descr = strdup(descr[0] ? descr : _("(Untitled)"));
Cheats[NumCheats].Enabled = 0;
Cheats[NumCheats].WasEnabled = 0;
Cheats[NumCheats].First = NumCodes;
Cheats[NumCheats].Enabled = 0;
Cheats[NumCheats].WasEnabled = 0;
Cheats[NumCheats].First = NumCodes;
+ Cheats[NumCheats].Descr = strdup(descr[0] ? descr : _("(Untitled)"));
assert(index >= 0 && index < NumCheats);
free(Cheats[index].Descr);
assert(index >= 0 && index < NumCheats);
free(Cheats[index].Descr);
+ Cheats[index].Descr = NULL;
while (index < NumCheats - 1) {
Cheats[index] = Cheats[index + 1];
while (index < NumCheats - 1) {
Cheats[index] = Cheats[index + 1];
int SaveState(const char *file) {
void *f;
int SaveState(const char *file) {
void *f;
- GPUFreeze_t *gpufP;
- SPUFreezeHdr_t *spufH;
- SPUFreeze_t *spufP;
+ GPUFreeze_t *gpufP = NULL;
+ SPUFreezeHdr_t spufH;
+ SPUFreeze_t *spufP = NULL;
+ unsigned char *pMem = NULL;
+ int result = -1;
f = SaveFuncs.open(file, "wb");
if (f == NULL) return -1;
f = SaveFuncs.open(file, "wb");
if (f == NULL) return -1;
SaveFuncs.write(f, (void *)&Config.HLE, sizeof(boolean));
pMem = (unsigned char *)malloc(128 * 96 * 3);
SaveFuncs.write(f, (void *)&Config.HLE, sizeof(boolean));
pMem = (unsigned char *)malloc(128 * 96 * 3);
- if (pMem == NULL) return -1;
+ if (pMem == NULL) goto cleanup;
GPU_getScreenPic(pMem);
SaveFuncs.write(f, pMem, 128 * 96 * 3);
free(pMem);
GPU_getScreenPic(pMem);
SaveFuncs.write(f, pMem, 128 * 96 * 3);
free(pMem);
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
+ if (gpufP == NULL) goto cleanup;
gpufP->ulFreezeVersion = 1;
GPU_freeze(1, gpufP);
SaveFuncs.write(f, gpufP, sizeof(GPUFreeze_t));
gpufP->ulFreezeVersion = 1;
GPU_freeze(1, gpufP);
SaveFuncs.write(f, gpufP, sizeof(GPUFreeze_t));
+ free(gpufP); gpufP = NULL;
- spufH = malloc(sizeof(*spufH));
- SPU_freeze(2, (SPUFreeze_t *)spufH, psxRegs.cycle);
- Size = spufH->Size; SaveFuncs.write(f, &Size, 4);
- free(spufH);
+ SPU_freeze(2, (SPUFreeze_t *)&spufH, psxRegs.cycle);
+ Size = spufH.Size; SaveFuncs.write(f, &Size, 4);
spufP = (SPUFreeze_t *) malloc(Size);
spufP = (SPUFreeze_t *) malloc(Size);
+ if (spufP == NULL) goto cleanup;
SPU_freeze(1, spufP, psxRegs.cycle);
SaveFuncs.write(f, spufP, Size);
SPU_freeze(1, spufP, psxRegs.cycle);
SaveFuncs.write(f, spufP, Size);
+ free(spufP); spufP = NULL;
sioFreeze(f, 1);
cdrFreeze(f, 1);
sioFreeze(f, 1);
cdrFreeze(f, 1);
mdecFreeze(f, 1);
new_dyna_freeze(f, 1);
mdecFreeze(f, 1);
new_dyna_freeze(f, 1);
}
int LoadState(const char *file) {
void *f;
}
int LoadState(const char *file) {
void *f;
- GPUFreeze_t *gpufP;
- SPUFreeze_t *spufP;
+ GPUFreeze_t *gpufP = NULL;
+ SPUFreeze_t *spufP = NULL;
int Size;
char header[32];
u32 version;
boolean hle;
int Size;
char header[32];
u32 version;
boolean hle;
f = SaveFuncs.open(file, "rb");
if (f == NULL) return -1;
f = SaveFuncs.open(file, "rb");
if (f == NULL) return -1;
SaveFuncs.read(f, &hle, sizeof(boolean));
if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion) {
SaveFuncs.read(f, &hle, sizeof(boolean));
if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion) {
- SaveFuncs.close(f);
- return -1;
+ SysPrintf("incompatible savestate version %x\n", version);
+ goto cleanup;
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
+ if (gpufP == NULL) goto cleanup;
SaveFuncs.read(f, gpufP, sizeof(GPUFreeze_t));
GPU_freeze(0, gpufP);
free(gpufP);
SaveFuncs.read(f, gpufP, sizeof(GPUFreeze_t));
GPU_freeze(0, gpufP);
free(gpufP);
// spu
SaveFuncs.read(f, &Size, 4);
spufP = (SPUFreeze_t *)malloc(Size);
// spu
SaveFuncs.read(f, &Size, 4);
spufP = (SPUFreeze_t *)malloc(Size);
+ if (spufP == NULL) goto cleanup;
SaveFuncs.read(f, spufP, Size);
SPU_freeze(0, spufP, psxRegs.cycle);
free(spufP);
SaveFuncs.read(f, spufP, Size);
SPU_freeze(0, spufP, psxRegs.cycle);
free(spufP);
mdecFreeze(f, 0);
new_dyna_freeze(f, 0);
mdecFreeze(f, 0);
new_dyna_freeze(f, 0);
}
int CheckState(const char *file) {
}
int CheckState(const char *file) {
if (iPPFNum <= 0) return;
pc = ppfCache = (PPF_CACHE *)malloc(iPPFNum * sizeof(PPF_CACHE));
if (iPPFNum <= 0) return;
pc = ppfCache = (PPF_CACHE *)malloc(iPPFNum * sizeof(PPF_CACHE));
+ if (pc == NULL) return;
static void AddToPPF(s32 ladr, s32 pos, s32 anz, unsigned char *ppfmem) {
if (ppfHead == NULL) {
ppfHead = (PPF_DATA *)malloc(sizeof(PPF_DATA) + anz);
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;
ppfHead->addr = ladr;
ppfHead->pNext = NULL;
ppfHead->pos = pos;
}
padd = (PPF_DATA *)malloc(sizeof(PPF_DATA) + anz);
}
padd = (PPF_DATA *)malloc(sizeof(PPF_DATA) + anz);
+ if (padd == NULL) return;
padd->addr = ladr;
padd->pNext = p;
padd->pos = pos;
padd->addr = ladr;
padd->pNext = p;
padd->pos = pos;
fclose(f);
}
f = fopen(mcd, "r+");
fclose(f);
}
f = fopen(mcd, "r+");
s = s + 3904;
fputc('1', f); s--;
fputc('2', f); s--;
s = s + 3904;
fputc('1', f); s--;
fputc('2', f); s--;
fclose(f);
}
f = fopen(mcd, "r+");
fclose(f);
}
f = fopen(mcd, "r+");
s = s + 64;
fputc('V', f); s--;
fputc('g', f); s--;
s = s + 64;
fputc('V', f); s--;
fputc('g', f); s--;