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

Fallback to not using mmap if buffer is not large enough #6510

Merged
merged 1 commit into from Aug 31, 2022

Conversation

radarhere
Copy link
Member

Resolves #6507

The issue found an image that hits

Pillow/src/map.c

Lines 116 to 117 in 6b35dc2

if (offset + size > view.len) {
PyErr_SetString(PyExc_ValueError, "buffer is not large enough");

However, that is when it uses mmap, and the image loads correctly without mmap. The explanation would be that the image is truncated, but not critically so.

This PR copies the "buffer is not large enough" into Python, and switches back to normal image loading if the condition fails.

The test image was created by copying one of our existing test images and truncating.

@hugovk hugovk merged commit b607e83 into python-pillow:main Aug 31, 2022
@radarhere radarhere deleted the buffer branch August 31, 2022 10:51
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.

ValueError: buffer is not large enough
2 participants