GUAC-240: Ensure initialization of last_pixel is obvious.

This commit is contained in:
Michael Jumper 2015-09-18 11:38:22 -07:00
parent f17fbf28ea
commit 7cb632c5c9

View File

@ -343,25 +343,27 @@ static int __guac_common_surface_png_optimality(guac_common_surface* surface,
/* Get buffer from surface */ /* Get buffer from surface */
unsigned char* buffer = surface->buffer + rect->y * stride + rect->x * 4; unsigned char* buffer = surface->buffer + rect->y * stride + rect->x * 4;
/* Image must be at least 1x1 */
if (width < 1 || height < 1)
return 0;
/* For each row */ /* For each row */
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
uint32_t last_pixel;
uint32_t* row = (uint32_t*) buffer; uint32_t* row = (uint32_t*) buffer;
uint32_t last_pixel = *(row++) | 0xFF000000;
/* For each pixel in current row */ /* For each pixel in current row */
for (x = 0; x < width; x++) { for (x = 1; x < width; x++) {
/* Get next pixel */ /* Get next pixel */
uint32_t current_pixel = *(row++) | 0xFF000000; uint32_t current_pixel = *(row++) | 0xFF000000;
/* Update same/different counts according to pixel value */ /* Update same/different counts according to pixel value */
if (x != 0) {
if (current_pixel == last_pixel) if (current_pixel == last_pixel)
num_same++; num_same++;
else else
num_different++; num_different++;
}
last_pixel = current_pixel; last_pixel = current_pixel;