Skip to content

SegFault when applying redactions overlapping a transparent image #1824

@JorjMcKie

Description

@JorjMcKie

Please provide all mandatory information!

Describe the bug (mandatory)

If a redaction rectangle overlaps an image with a mask (= image with transparency) and page.apply_redactions(images=fitz.PDF_REDACT_IMAGE_PIXELS) is used (the default), the interpreter crashes with segmentation fault. Verified under Linux and Windows.

To Reproduce (mandatory)

Execute with the attached reproducer PDF:

import fitz
doc=fitz.open("input.pdf")
page=doc[0]
page.apply_redactions()

input.pdf

Your configuration (mandatory)

In [2]: print(fitz.__doc__)

PyMuPDF 1.20.0: Python bindings for the MuPDF 1.20.1 library.
Version date: 2022-06-27 00:00:01.
Built for Python 3.9 on win32 (64-bit).
In [2]: print(fitz.__doc__)

PyMuPDF 1.20.0: Python bindings for the MuPDF 1.20.1 library.
Version date: 2022-06-27 00:00:01.
Built for Python 3.8 on linux (64-bit).

Additional context (optional)

This is also the case for other Python versions - tested up to Python 3.10.
It did work (although with bugs - see comment at the bottom of this) in v 1.19.x.
When recompiling under Windows (Linux yet to be confirmed), things will work again as before.
The error occurs in

grafik

which invokes this C-code:

grafik


Please note that for transparent images, the MuPDF code will produce a PNG image without transparency.
This is a known problem and does not otherwise interfere with this bug.
Using one of the other options for handling images with redactions continue to work fine.

Metadata

Metadata

Assignees

Labels

upstream bugbug outside this package

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions