Skip to content

Commit 18e2877

Browse files
committed
Only convert to int if there are enough items
1 parent 237aea4 commit 18e2877

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/PIL/GimpPaletteFile.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def __init__(self, fp: IO[bytes]) -> None:
4545
msg = "bad palette file"
4646
raise SyntaxError(msg)
4747

48-
v = tuple(map(int, s.split(maxsplit=3)[:3]))
49-
if len(v) != 3:
48+
v = s.split(maxsplit=3)
49+
if len(v) < 3:
5050
msg = "bad palette entry"
5151
raise ValueError(msg)
5252

53-
palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2])
53+
palette[i] = o8(int(v[0])) + o8(int(v[1])) + o8(int(v[2]))
5454

5555
self.palette = b"".join(palette)
5656

0 commit comments

Comments
 (0)