File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,12 @@ def read_comment(s: str) -> bool:
310310 # Check for an "ImageData" descriptor
311311 # https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096
312312
313+ # If we've already read an "ImageData" descriptor,
314+ # don't read another one.
315+ if imagedata_size :
316+ bytes_read = 0
317+ continue
318+
313319 # Values:
314320 # columns
315321 # rows
@@ -320,10 +326,6 @@ def read_comment(s: str) -> bool:
320326 # binary/ascii (1: binary, 2: ascii)
321327 # data start identifier (the image data follows after a single line
322328 # consisting only of this quoted value)
323- if imagedata_size :
324- bytes_read = 0
325- continue
326-
327329 image_data_values = byte_arr [11 :bytes_read ].split (None , 7 )
328330 columns , rows , bit_depth , mode_id = (
329331 int (value ) for value in image_data_values [:4 ]
@@ -339,6 +341,8 @@ def read_comment(s: str) -> bool:
339341 else :
340342 break
341343
344+ # Read the columns and rows after checking the bit depth and mode
345+ # in case the bit depth and/or mode are invalid.
342346 imagedata_size = columns , rows
343347 elif bytes_mv [:5 ] == b"%%EOF" :
344348 break
You can’t perform that action at this time.
0 commit comments