PDB Input: Ingore malformed metadata records. Fixes #1499878 [Plucker pdb files fail to load](https://bugs.launchpad.net/calibre/+bug/1499878)

This commit is contained in:
Kovid Goyal 2015-09-26 08:47:42 +05:30
parent 648b73541a
commit ffff07bdd3
2 changed files with 8 additions and 4 deletions

View File

@ -44,8 +44,10 @@ def get_metadata(stream, extract_cover=True):
author = None
pubdate = 0
for i in xrange(record_count):
type, = struct.unpack('>H', section_data[2+adv:4+adv])
length, = struct.unpack('>H', section_data[4+adv:6+adv])
try:
type, length = struct.unpack_from('>HH', section_data, 2 + adv)
except struct.error:
break
# CharSet
if type == 1:

View File

@ -199,8 +199,10 @@ class SectionMetadata(object):
adv = 0
for i in xrange(record_count):
type, = struct.unpack('>H', raw[2+adv:4+adv])
length, = struct.unpack('>H', raw[4+adv:6+adv])
try:
type, length = struct.unpack_from('>HH', raw, 2 + adv)
except struct.error:
break
# CharSet
if type == 1: