Repository navigation
Initialize offset memory for PyImagingPhotoPut - #4806
Merged
Merged
Conversation
nqbit
marked this pull request as ready for review
July 21, 2020 07:05
Member
|
Are you aware of a situation that shows this bug? We would be interested in adding such a scenario as a test. |
Contributor
Author
|
This was caught with a memory sanitizer, see the following example: import numpy as np
from PIL import Image
from PIL import ImageTk
example_image_array = np.full((100,100), 123, dtype=np.uint8)
example_image = Image.fromarray(example_image_array)
example_image_tk = ImageTk.PhotoImage(image=example_image)Is there currently any support for memory sanitization in the test framework? |
When using image mode "1" or "L" block.offset[3] is never initialized. In some use cases the block is passed to Tk_PhotoPutBlock (https://github.com/tcltk/tk/blob/master/generic/tkImgPhoto.c#L2752) and block.offset[3] is stored in alphaoffset which is later referenced.
Member
|
The closest we have to memory sanitization testing is #3961. As such, while I agree that your change makes logical sense, I'm having trouble running a sanitizer over the code, since Tkinter requires a display, and my usual approach to this problem would be display-less docker. |
Contributor
Author
|
Thank you for helping to get this merged. One option for display-less configuration is xvfb (X virtual frame-buffer). https://en.wikipedia.org/wiki/Xvfb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using image mode "1" or "L" block.offset[3] is never initialized. In some use cases the block is passed to Tk_PhotoPutBlock (https://github.com/tcltk/tk/blob/master/generic/tkImgPhoto.c#L2752) and block.offset[3] is stored in alphaoffset which is later referenced.
This change initializes block.offset[3] to 0 when using mode "1" or "L".