Skip to content

Commit

Permalink
Updated index pack constructor to improve generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcferrill committed Jun 30, 2021
1 parent 64abc15 commit 0412650
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chapter10/computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __repr__(self):
def __init__(self, *args, **kwargs):
packet.Packet.__init__(self, *args, **kwargs)

if self.file_size_present:
if self.file_size_present and self.buffer:
self.file_size, = bitstruct.unpack('u64<', self.buffer.read(8))

fmt = 'u64 ipts'
Expand All @@ -195,7 +195,7 @@ def __init__(self, *args, **kwargs):

self.Message.FORMAT = BitFormat(fmt)

if self.index_type == 0:
if self.index_type == 0 and self.buffer:
pos = self.buffer.tell()
self.buffer.seek(self.data_length - 8)
self.root_offset, = bitstruct.unpack('u64<', self.buffer.read(8))
Expand Down

0 comments on commit 0412650

Please sign in to comment.