Skip to content
New issue

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

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

Already on GitHub? # to your account

PCD decoder overruns the shuffle buffer, Fixes #568 #1706

Merged
merged 2 commits into from
Feb 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Tests/images/hopper.pcd
Binary file not shown.
22 changes: 22 additions & 0 deletions Tests/test_file_pcd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from helper import unittest, PillowTestCase, hopper
from PIL import Image

class TestFilePcd(PillowTestCase):

def test_load_raw(self):
im = Image.open('Tests/images/hopper.pcd')
im.load() # should not segfault.

# Note that this image was created with a resized hopper
# image, which was then converted to pcd with imagemagick
# and the colors are wonky in Pillow. It's unclear if this
# is a pillow or a convert issue, as other images not generated
# from convert look find on pillow and not imagemagick.

#target = hopper().resize((768,512))
#self.assert_image_similar(im, target, 10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why are these lines commented?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I realise again that the comment explains it. This is a potential future test, a kind of todo if you will.



if __name__ == '__main__':
unittest.main()

4 changes: 2 additions & 2 deletions libImaging/PcdDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ImagingPcdDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
out[0] = ptr[x];
out[1] = ptr[(x+4*state->xsize)/2];
out[2] = ptr[(x+5*state->xsize)/2];
out += 4;
out += 3;
}

state->shuffle((UINT8*) im->image[state->y],
Expand All @@ -62,7 +62,7 @@ ImagingPcdDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
out[0] = ptr[x+state->xsize];
out[1] = ptr[(x+4*state->xsize)/2];
out[2] = ptr[(x+5*state->xsize)/2];
out += 4;
out += 3;
}

state->shuffle((UINT8*) im->image[state->y],
Expand Down