Test: Fix crash when fuzzing fails to load a file

This commit is contained in:
Vicki Pfau 2017-04-24 13:35:28 -07:00
parent 422c3a25b8
commit 870c375cf6
2 changed files with 9 additions and 2 deletions

View File

@ -47,6 +47,7 @@ Bugfixes:
- Core: Fix crash with rewind if savestates shrink
- Test: Fix crash when loading invalid file
- GBA Hardware: Fix crash if a savestate lies about game hardware
- Test: Fix crash when fuzzing fails to load a file
Misc:
- SDL: Remove scancode key input
- GBA Video: Clean up unused timers

View File

@ -94,10 +94,15 @@ int main(int argc, char** argv) {
#ifdef __AFL_HAVE_MANUAL_CONTROL
__AFL_INIT();
#endif
bool cleanExit = true;
if (!mCoreLoadFile(core, args.fname)) {
cleanExit = false;
goto loadError;
}
if (args.patch) {
core->loadPatch(core, VFileOpen(args.patch, O_RDONLY));
}
mCoreLoadFile(core, args.fname);
struct VFile* savestate = 0;
struct VFile* savestateOverlay = 0;
@ -158,13 +163,14 @@ int main(int argc, char** argv) {
savestateOverlay->close(savestateOverlay);
}
loadError:
freeArguments(&args);
if (outputBuffer) {
free(outputBuffer);
}
core->deinit(core);
return 0;
return !cleanExit;
}
static void _fuzzRunloop(struct mCore* core, int frames) {