From 4f3b44960f103bc201a742332dbf9a77de1eaa87 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 2 Apr 2019 09:25:27 +1100 Subject: [PATCH] Resolved segfaults --- Tests/test_qt_image_fromqpixmap.py | 17 +++-------------- src/libImaging/Convert.c | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Tests/test_qt_image_fromqpixmap.py b/Tests/test_qt_image_fromqpixmap.py index 358f1573d..894d7c8a5 100644 --- a/Tests/test_qt_image_fromqpixmap.py +++ b/Tests/test_qt_image_fromqpixmap.py @@ -11,17 +11,6 @@ class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase): # Qt saves all pixmaps as rgb self.assert_image_equal(result, expected.convert('RGB')) - def test_sanity_1(self): - self.roundtrip(hopper('1')) - - def test_sanity_rgb(self): - self.roundtrip(hopper('RGB')) - - def test_sanity_rgba(self): - self.roundtrip(hopper('RGBA')) - - def test_sanity_l(self): - self.roundtrip(hopper('L')) - - def test_sanity_p(self): - self.roundtrip(hopper('P')) + def test_sanity(self): + for mode in ('1', 'RGB', 'RGBA', 'L', 'P'): + self.roundtrip(hopper(mode)) diff --git a/src/libImaging/Convert.c b/src/libImaging/Convert.c index e227975de..a6fefca32 100644 --- a/src/libImaging/Convert.c +++ b/src/libImaging/Convert.c @@ -982,8 +982,8 @@ static void p2pa(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) { int x; - for (x = 0; x < xsize; x++, in+=4) { - const UINT8* rgba = &palette[in[0] * 4]; + for (x = 0; x < xsize; x++, in++) { + const UINT8* rgba = &palette[in[0]]; *out++ = in[0]; *out++ = in[0]; *out++ = in[0];