Test: Fix crash when fuzzing fails to load a file
Vicki Pfau vi@endrift.com
Mon, 24 Apr 2017 13:35:28 -0700
2 files changed,
9 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -47,6 +47,7 @@ - Qt: Ensure CLI backend is attached when submitting commands (fixes mgba.io/i/662)
- 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
M
src/platform/test/fuzz-main.c
→
src/platform/test/fuzz-main.c
@@ -94,10 +94,15 @@
#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 @@ if (savestateOverlay) {
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) {