From 464453ad651598012b3c50880b1b0e423cc69919 Mon Sep 17 00:00:00 2001 From: Dave Allie Date: Wed, 24 Dec 2025 20:26:35 +1000 Subject: [PATCH] Fix off by one error in book metadata cache look up tables --- lib/Epub/Epub/BookMetadataCache.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Epub/Epub/BookMetadataCache.cpp b/lib/Epub/Epub/BookMetadataCache.cpp index e5cffd59..a2ef25d8 100644 --- a/lib/Epub/Epub/BookMetadataCache.cpp +++ b/lib/Epub/Epub/BookMetadataCache.cpp @@ -106,15 +106,17 @@ bool BookMetadataCache::buildBookBin(const std::string& epubPath, const BookMeta // Loop through spine entries, writing LUT positions spineFile.seek(0); for (int i = 0; i < spineCount; i++) { + auto pos = spineFile.position(); auto spineEntry = readSpineEntry(spineFile); - serialization::writePod(bookFile, spineFile.position() + lutOffset + lutSize); + serialization::writePod(bookFile, pos + lutOffset + lutSize); } // Loop through toc entries, writing LUT positions tocFile.seek(0); for (int i = 0; i < tocCount; i++) { + auto pos = tocFile.position(); auto tocEntry = readTocEntry(tocFile); - serialization::writePod(bookFile, tocFile.position() + lutOffset + lutSize + spineFile.position()); + serialization::writePod(bookFile, pos + lutOffset + lutSize + spineFile.position()); } // LUTs complete