Skip to content
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

New Pixmap from pixmap crashes interpreter for unsupported colorspace #67

Closed
JorjMcKie opened this issue Aug 23, 2016 · 0 comments
Closed
Assignees
Labels

Comments

@JorjMcKie
Copy link
Collaborator

If a pixmap pix0 has a colorspace unsupported by MuPDF (i.e. one generated from image files), trial to convert it with pix1 = fitz.Pixmap(my_cspace, pix0) will crash the Python interpreter.

This can e.g. occur when the image source contains only black & white with no alpha channel. Then pix0.n will equal 1.

Fix:

Check 2 <= pix0.n <= 5 and raise an exception otherwise. This has been tested already and will soon be uploaded.

Circumvention:

Amazingly, pix0.writePNG(...) and pix0.getPNGData() will still both work in such situations! So, whenever pix0.n is not in valid range, do pix00 = fitz.Pixmap(pix0.getPNGData()) and then do pix1 = fitz.Pixmap(my_cspace, pix00)

@JorjMcKie JorjMcKie added the bug label Aug 23, 2016
@JorjMcKie JorjMcKie self-assigned this Aug 25, 2016
JorjMcKie added a commit that referenced this issue Aug 25, 2016
JorjMcKie added a commit that referenced this issue Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant