From e69f6b85794e87730aded713919c535e634add45 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 21 Jul 2025 23:53:54 +0300 Subject: [PATCH] Bug fix: GB_save_state always returned success --- Core/save_state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/save_state.c b/Core/save_state.c index ab9813c..cc0330d 100644 --- a/Core/save_state.c +++ b/Core/save_state.c @@ -551,6 +551,7 @@ static const uint8_t *get_header_bank(GB_gameboy_t *gb) static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool append_bess) { + errno = 0; if (file->write(file, GB_GET_SECTION(gb, header), GB_SECTION_SIZE(header)) != GB_SECTION_SIZE(header)) goto error; if (!DUMP_SECTION(gb, file, core_state)) goto error; if (!DUMP_SECTION(gb, file, dma )) goto error; @@ -838,8 +839,10 @@ static int save_state_internal(GB_gameboy_t *gb, virtual_file_t *file, bool appe goto error; } + return 0;; error: - return 0; + if (errno == 0) return EIO; + return errno; } int GB_save_state(GB_gameboy_t *gb, const char *path)