Skip to content

Commit 95a4928

Browse files
authored
Fix colored hexdumps for zero-length field values (#84)
1 parent 6a6cde0 commit 95a4928

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dissect/cstruct/utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ def _hexdump(data: bytes, palette: Palette = None, offset: int = 0, prefix: str
5555
for j in range(16):
5656
if not active and palette:
5757
remaining, active = palette.pop()
58+
while remaining == 0:
59+
if len(palette) == 0:
60+
# Last palette tuple is empty: print remaining whitespaces
61+
active = ""
62+
break
63+
else:
64+
remaining, active = palette.pop()
5865
values += active
5966
elif active and j == 0:
6067
values += active

0 commit comments

Comments
 (0)