From 8b6db63788e87695cdef4e715896ccfe48b3a40b Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 17 Apr 2026 16:33:15 +0200 Subject: [PATCH] Add guard --- src/JsonSettingsIO.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/JsonSettingsIO.cpp b/src/JsonSettingsIO.cpp index 4dc6811e..b09692d0 100644 --- a/src/JsonSettingsIO.cpp +++ b/src/JsonSettingsIO.cpp @@ -95,14 +95,13 @@ bool JsonSettingsIO::saveState(const CrossPointState& s, const char* path) { jump["spineIndex"] = s.pendingBookmarkJump.spineIndex; jump["pageNumber"] = s.pendingBookmarkJump.pageNumber; - FsFile file; - if (!Storage.openFileForWrite("CPS", path, file)) { + if (doc.overflowed()) { + LOG_ERR("CPS", "JSON document overflowed while building state"); return false; } - if (doc.overflowed()) { - LOG_ERR("CPS", "JSON document overflowed while building state"); - file.close(); + FsFile file; + if (!Storage.openFileForWrite("CPS", path, file)) { return false; }