all repos — mgba @ c665f939e72d227189fd8064a1899f3724099147

mGBA Game Boy Advance Emulator

Core: Don't save state if core fails to serialize
Vicki Pfau vi@endrift.com
Wed, 05 Apr 2017 14:45:53 -0700
commit

c665f939e72d227189fd8064a1899f3724099147

parent

472faf3881f879b3a479266183270cf2ff64a141

2 files changed, 4 insertions(+), 5 deletions(-)

jump to
M CHANGESCHANGES

@@ -38,6 +38,7 @@ - SDL: Fix game crash check

- SDL: Fix race condition with audio thread when starting - GB: Fix flickering when screen is strobed quickly - FFmpeg: Fix overflow and general issues with audio encoding + - Core: Don't save state if core fails to serialize Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers
M src/core/serialize.csrc/core/serialize.c

@@ -160,10 +160,9 @@ }

size_t stateSize = core->stateSize(core); void* state = anonymousMemoryMap(stateSize); - if (!state) { + if (!state || !core->saveState(core, state)) { return false; } - core->saveState(core, state); uLongf len = compressBound(stateSize); void* buffer = malloc(len);

@@ -343,15 +342,14 @@ #else

UNUSED(flags); #endif vf->truncate(vf, stateSize); - struct GBASerializedState* state = vf->map(vf, stateSize, MAP_WRITE); - if (!state) { + void* state = vf->map(vf, stateSize, MAP_WRITE); + if (!state || !core->saveState(core, state)) { mStateExtdataDeinit(&extdata); if (cheatVf) { cheatVf->close(cheatVf); } return false; } - core->saveState(core, state); vf->unmap(vf, state, stateSize); vf->seek(vf, stateSize, SEEK_SET); mStateExtdataSerialize(&extdata, vf);