From fd7cf5e221f73987a7ab6d9278cbbd13aabc84c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Sun, 7 Nov 2021 20:20:32 +0100 Subject: [PATCH] file: write: return error if fflush failed --- src/devices/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/devices/file.c b/src/devices/file.c index 523aac3..4ce647a 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -109,17 +109,17 @@ file_read(void *dest, Uint16 len) Uint16 file_write(void *src, Uint16 len, Uint8 flags) { + Uint16 ret = 0; if(state != FILE_WRITE) { reset(); if((f = fopen(current_filename, (flags & 0x01) ? "ab" : "wb")) != NULL) state = FILE_WRITE; } if(state == FILE_WRITE) { - Uint16 ret = fwrite(src, 1, len, f); - fflush(f); - return ret; + if((ret = fwrite(src, 1, len, f)) > 0 && fflush(f) != 0) + ret = 0; } - return 0; + return ret; } Uint16