Skip to content

Commit

Permalink
When unpacking, compute size without adjusting for alignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
dperelman authored and tych0 committed Jun 24, 2019
1 parent 5f33fff commit 3e58294
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ def pad(self, thing):
self.offset += type_pad(size, self.offset)

def unpack(self, fmt, increment=True):
fmt = "=" + fmt
size = struct.calcsize(fmt)
if size > self.size - self.offset:
self._resize(size)
ret = struct.unpack_from("=" + fmt, self.buf, self.offset)
ret = struct.unpack_from(fmt, self.buf, self.offset)

if increment:
self.offset += size
Expand Down

0 comments on commit 3e58294

Please sign in to comment.