From 380729e9822d560182aee2cb2e66d13e9ff0e7f8 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 14 Dec 2016 09:05:19 -0800 Subject: [PATCH] Fix a warning in jpeg compression code with --enable-jpeg If the image width is not divisible by 4, the image is padded to the next multiple of 4. The additional pixels are filled with the colors of the last pixel in the row. The last pixel colors may not be initialized if the width is 0. In this case, the would be no padding, but the compiler doesn't know that. Add a check that the width is more that 0 before filling the padding. --- libxrdp/xrdp_jpeg_compress.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libxrdp/xrdp_jpeg_compress.c b/libxrdp/xrdp_jpeg_compress.c index 385203a6..755c20bd 100644 --- a/libxrdp/xrdp_jpeg_compress.c +++ b/libxrdp/xrdp_jpeg_compress.c @@ -365,11 +365,14 @@ jpeg_compress(char *in_data, int width, int height, *(dst8++) = red; } - for (i = 0; i < e; i++) + if (width > 0) { - *(dst8++) = blue; - *(dst8++) = green; - *(dst8++) = red; + for (i = 0; i < e; i++) + { + *(dst8++) = blue; + *(dst8++) = green; + *(dst8++) = red; + } } } }