Skip to content

Commit 13915a8

Browse files
committed
WINTERMUTE: Gracefully handle end of file
1 parent e656002 commit 13915a8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

engines/wintermute/dcp_extractor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def read_struct(f, fmt, constructor):
3636
def read_str(f):
3737
sz = f.read(1)
3838
if len(sz) != 1:
39-
raise Exception("File too small")
39+
print("End of file!")
40+
return ""
4041
sz, = struct.unpack('<B', sz)
4142
s = f.read(sz)
4243
if len(s) != sz:
@@ -69,6 +70,8 @@ def read_headers(f, abs_offset = 0):
6970

7071
for i in range(dirent.num_entries):
7172
fname = read_str(f)
73+
if (fname == ""):
74+
break
7275
fname = bytes(b ^ 0x44 for b in fname)
7376
fname = fname.rstrip(b'\x00')
7477

0 commit comments

Comments
 (0)