forked from openlp/openlp
Fix bug in reading memo files larger than 16MiB
This commit is contained in:
parent
4f11181bfa
commit
6504397662
@ -249,19 +249,20 @@ class EasyWorshipSongImport(SongImport):
|
|||||||
return (field ^ 0x80 == 1)
|
return (field ^ 0x80 == 1)
|
||||||
elif field_desc.type == 0x0c or field_desc.type == 0x0d:
|
elif field_desc.type == 0x0c or field_desc.type == 0x0d:
|
||||||
# Memo or Blob
|
# Memo or Blob
|
||||||
sub_block, block_start, blob_size = \
|
block_start, blob_size = \
|
||||||
struct.unpack_from('<bhxi', field, len(field)-10)
|
struct.unpack_from('<II', field, len(field)-10)
|
||||||
self.memo_file.seek(block_start * 256)
|
sub_block = block_start & 0xff;
|
||||||
|
block_start &= ~0xff
|
||||||
|
self.memo_file.seek(block_start)
|
||||||
memo_block_type, = struct.unpack('b', self.memo_file.read(1))
|
memo_block_type, = struct.unpack('b', self.memo_file.read(1))
|
||||||
if memo_block_type == 2:
|
if memo_block_type == 2:
|
||||||
self.memo_file.seek(8, os.SEEK_CUR)
|
self.memo_file.seek(8, os.SEEK_CUR)
|
||||||
elif memo_block_type == 3:
|
elif memo_block_type == 3:
|
||||||
if sub_block < 0 or sub_block > 63:
|
if sub_block > 63:
|
||||||
return u'';
|
return u'';
|
||||||
self.memo_file.seek(11 + (5 * sub_block), os.SEEK_CUR)
|
self.memo_file.seek(11 + (5 * sub_block), os.SEEK_CUR)
|
||||||
sub_block_start, = struct.unpack('B', self.memo_file.read(1))
|
sub_block_start, = struct.unpack('B', self.memo_file.read(1))
|
||||||
self.memo_file.seek((block_start * 256) +
|
self.memo_file.seek(block_start + (sub_block_start * 16))
|
||||||
(sub_block_start * 16))
|
|
||||||
else:
|
else:
|
||||||
return u'';
|
return u'';
|
||||||
return self.memo_file.read(blob_size)
|
return self.memo_file.read(blob_size)
|
||||||
|
Loading…
Reference in New Issue
Block a user