all repos — mgba @ 09db378531bfe16c736f20cd62c79aa91d19b9d0

mGBA Game Boy Advance Emulator

Perf: Fix crash when the GBA thread fails to start
Jeffrey Pfau jeffrey@endrift.com
Sun, 25 Jan 2015 03:12:53 -0800
commit

09db378531bfe16c736f20cd62c79aa91d19b9d0

parent

e70df7b6f7e1d73f6489deb89ae9365e5f3edfd3

2 files changed, 14 insertions(+), 8 deletions(-)

jump to
M CHANGESCHANGES

@@ -28,6 +28,7 @@ - GBA BIOS: Fix BIOS prefetch after returning from an IRQ

- GBA BIOS: Fix BIOS prefetch after reset - GBA Memory: Fix alignment of open bus 8- and 16-bit loads - GBA Thread: Fix possible hang when loading an archive + - Perf: Fix crash when the GBA thread fails to start Misc: - GBA Audio: Change internal audio sample buffer from 32-bit to 16-bit samples - GBA Memory: Simplify memory API and use fixed bus width
M src/platform/perf-main.csrc/platform/perf-main.c

@@ -86,7 +86,11 @@ opts.videoSync = false;

GBAMapArgumentsToContext(&args, &context); GBAMapOptionsToContext(&opts, &context); - GBAThreadStart(&context); + int didStart = GBAThreadStart(&context); + + if (!didStart) { + goto cleanup; + } GBAGetGameCode(context.gba, gameCode); int frames = perfOpts.frames;

@@ -102,12 +106,6 @@ uint64_t end = 1000000LL * tv.tv_sec + tv.tv_usec;

uint64_t duration = end - start; GBAThreadJoin(&context); - GBAConfigFreeOpts(&opts); - freeArguments(&args); - GBAConfigDeinit(&config); - free(context.debugger); - - free(renderer.outputBuffer); float scaledFrames = frames * 1000000.f; if (perfOpts.csv) {

@@ -123,7 +121,14 @@ } else {

printf("%u frames in %" PRIu64 " microseconds: %g fps (%gx)\n", frames, duration, scaledFrames / duration, scaledFrames / (duration * 60.f)); } - return GBAThreadHasCrashed(&context); +cleanup: + GBAConfigFreeOpts(&opts); + freeArguments(&args); + GBAConfigDeinit(&config); + free(context.debugger); + free(renderer.outputBuffer); + + return !didStart || GBAThreadHasCrashed(&context); } static void _GBAPerfRunloop(struct GBAThread* context, int* frames, bool quiet) {