From 1e249c2d47238665f49bdeb124f7f8735133f039 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 15 Jun 2023 08:06:15 +0530 Subject: [PATCH] MOBI Input: Ignore another form of corruption in trailing bytes. Fixes #2023943 [Private bug](https://bugs.launchpad.net/calibre/+bug/2023943) --- src/calibre/ebooks/mobi/reader/mobi6.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/reader/mobi6.py b/src/calibre/ebooks/mobi/reader/mobi6.py index f3bb969272..de1f42f102 100644 --- a/src/calibre/ebooks/mobi/reader/mobi6.py +++ b/src/calibre/ebooks/mobi/reader/mobi6.py @@ -788,7 +788,10 @@ class MobiReader: flags >>= 1 if self.book_header.extra_flags & 1: off = size - num - 1 - num += (ord(data[off:off+1]) & 0x3) + 1 + try: + num += (ord(data[off:off+1]) & 0x3) + 1 + except TypeError: + num += 1 return num def warn_about_trailing_entry_corruption(self):