From 15aa3fb4720b1a94e1b5cd1a75fcf46a246cabde Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 14 Apr 2012 08:56:07 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/mobi/debug/headers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/debug/headers.py b/src/calibre/ebooks/mobi/debug/headers.py index 034c714d31..07a3fa91b9 100644 --- a/src/calibre/ebooks/mobi/debug/headers.py +++ b/src/calibre/ebooks/mobi/debug/headers.py @@ -308,8 +308,10 @@ class MOBIHeader(object): # {{{ self.extra_data_flags = 0 if self.has_extra_data_flags: self.unknown4 = self.raw[180:192] - self.fdst_idx, self.fdst_count = struct.unpack_from(b'>II', + self.fdst_idx, self.fdst_count = struct.unpack_from(b'>LL', self.raw, 192) + if self.fdst_count <= 1: + self.fdst_idx = NULL_INDEX (self.fcis_number, self.fcis_count, self.flis_number, self.flis_count) = struct.unpack(b'>IIII', self.raw[200:216]) @@ -342,7 +344,7 @@ class MOBIHeader(object): # {{{ 'first_non_book_record', 'datp_record_offset', 'fcis_number', 'flis_number', 'primary_index_record', 'fdst_idx', 'first_image_index'): - if hasattr(self, x): + if hasattr(self, x) and getattr(self, x) != NULL_INDEX: setattr(self, x, self.header_offset+getattr(self, x)) if self.has_exth: