Skip to content

Simplify check for GBR width and height #9089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

radarhere
Copy link
Member

  1. Simplify a check for width and height, as they cannot actually be less than zero.

    from ._binary import i32be as i32

    width = i32(self.fp.read(4))
    height = i32(self.fp.read(4))
    color_depth = i32(self.fp.read(4))
    if width <= 0 or height <= 0:

    def i32be(c: bytes, o: int = 0) -> int:
    return unpack_from(">I", c, o)[0]

    where I is an unsigned integer.

  2. Add coverage for the lines missing at https://app.codecov.io/gh/python-pillow/Pillow/blob/main/src%2FPIL%2FGbrImagePlugin.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant