From ad0fe6b6f9600600663bd1cd0f47ce5c6feefdf3 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 16 Oct 2019 16:06:06 -0400 Subject: [PATCH] image-loader: Fix undefined left shift in premultiply_data ../shared/image-loader.c:184:14: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' Store each channel in a uint32_t instead of a byte so we compute the shift over an unsigned type. --- shared/image-loader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/image-loader.c b/shared/image-loader.c index 8686e02a..2385c7a0 100644 --- a/shared/image-loader.c +++ b/shared/image-loader.c @@ -166,15 +166,15 @@ premultiply_data(png_structp png, png_bytep p; for (i = 0, p = data; i < row_info->rowbytes; i += 4, p += 4) { - png_byte alpha = p[3]; + uint32_t alpha = p[3]; uint32_t w; if (alpha == 0) { w = 0; } else { - png_byte red = p[0]; - png_byte green = p[1]; - png_byte blue = p[2]; + uint32_t red = p[0]; + uint32_t green = p[1]; + uint32_t blue = p[2]; if (alpha != 0xff) { red = multiply_alpha(alpha, red);