Skip to content

Commit e3b53dc

Browse files
committed
Use SAFEBLOCK instead of arbitrary large number
1 parent 0d5a2d2 commit e3b53dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PIL/PpmImagePlugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class PpmPlainDecoder(ImageFile.PyDecoder):
141141
_pulls_fd = True
142142

143143
def _read_block(self):
144-
return self.fd.read(10**6)
144+
return self.fd.read(ImageFile.SAFEBLOCK)
145145

146146
def _find_comment_end(self, block, start=0):
147147
a = block.find(b"\n", start)
@@ -186,8 +186,8 @@ def _decode_bitonal(self):
186186
while block and comment_spans:
187187
comment_end = self._find_comment_end(block)
188188
if comment_end != -1: # comment ends in this block
189-
comment_spans = False
190189
block = block[comment_end + 1 :] # delete tail of previous comment
190+
comment_spans = False
191191
else: # comment spans whole block
192192
block = self._read_block()
193193

0 commit comments

Comments
 (0)