File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,11 @@ 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, don't read another one.
314+ if imagedata_size :
315+ bytes_read = 0
316+ continue
317+
313318 # Values:
314319 # columns
315320 # rows
@@ -320,10 +325,6 @@ def read_comment(s: str) -> bool:
320325 # binary/ascii (1: binary, 2: ascii)
321326 # data start identifier (the image data follows after a single line
322327 # consisting only of this quoted value)
323- if imagedata_size :
324- bytes_read = 0
325- continue
326-
327328 image_data_values = byte_arr [11 :bytes_read ].split (None , 7 )
328329 columns , rows , bit_depth , mode_id = (
329330 int (value ) for value in image_data_values [:4 ]
@@ -339,6 +340,8 @@ def read_comment(s: str) -> bool:
339340 else :
340341 break
341342
343+ # Read the columns and rows after checking the bit depth and mode
344+ # in case the bit depth and/or mode are invalid.
342345 imagedata_size = columns , rows
343346 elif bytes_mv [:5 ] == b"%%EOF" :
344347 break
You can’t perform that action at this time.
0 commit comments