From be063529daebc47dcbe35c454174dd7b0c623cf0 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 5 Aug 2022 15:04:26 +0600 Subject: [PATCH] NVR: Don't fatal on failure to read NVR properly --- src/nvr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nvr.c b/src/nvr.c index b73aa6fa7..a68331e34 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -237,6 +237,7 @@ nvr_load(void) { char *path; FILE *fp; + uint8_t regs[NVR_MAXSIZE] = { 0 }; /* Make sure we have been initialized. */ if (saved_nvr == NULL) return(0); @@ -255,9 +256,12 @@ nvr_load(void) fp = plat_fopen(path, "rb"); saved_nvr->is_new = (fp == NULL); if (fp != NULL) { + memcpy(regs, saved_nvr->regs, sizeof(regs)); /* Read NVR contents from file. */ - if (fread(saved_nvr->regs, 1, saved_nvr->size, fp) != saved_nvr->size) - fatal("nvr_load(): Error reading data\n"); + if (fread(saved_nvr->regs, 1, saved_nvr->size, fp) != saved_nvr->size) { + memcpy(saved_nvr->regs, regs, sizeof(regs)); + saved_nvr->is_new = 1; + } (void)fclose(fp); } } else