-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
When looking through the code for understanding #2158, I stumbled upon some possibly undefined variable.
Let's take the following snippet:
Lines 143 to 165 in 05f2a65
| if isinstance(decode_parms, ArrayObject): | |
| columns = 1 | |
| bits_per_component = DEFAULT_BITS_PER_COMPONENT | |
| for decode_parm in decode_parms: | |
| if "/Columns" in decode_parm: | |
| columns = decode_parm["/Columns"] | |
| if LZW.BITS_PER_COMPONENT in decode_parm: | |
| bits_per_component = decode_parm[LZW.BITS_PER_COMPONENT] | |
| else: | |
| columns = ( | |
| 1 if decode_parms is None else decode_parms.get(LZW.COLUMNS, 1) | |
| ) | |
| colors = 1 if decode_parms is None else decode_parms.get(LZW.COLORS, 1) | |
| bits_per_component = ( | |
| decode_parms.get(LZW.BITS_PER_COMPONENT, DEFAULT_BITS_PER_COMPONENT) | |
| if decode_parms | |
| else DEFAULT_BITS_PER_COMPONENT | |
| ) | |
| # PNG predictor can vary by row and so is the lead byte on each row | |
| rowlength = ( | |
| math.ceil(columns * colors * bits_per_component / 8) + 1 | |
| ) # number of bytes |
It seems like in the first branch (lines 144 to 150), colors will never be defined, thus possibly leading to a crash at line 164 if I did not miss something. (I do not have any PDF file for this, as I just stumbled upon this by accident.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels