diff --git a/win32ss/user/user32/windows/cursoricon.c b/win32ss/user/user32/windows/cursoricon.c index 6299c83900..e6e53bd74f 100644 --- a/win32ss/user/user32/windows/cursoricon.c +++ b/win32ss/user/user32/windows/cursoricon.c @@ -115,22 +115,20 @@ static int get_dib_image_size( int width, int height, int depth ) static BOOL is_dib_monochrome( const BITMAPINFO* info ) { + BOOL found_black = FALSE, found_white = FALSE; if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { const RGBTRIPLE *rgb = ((const BITMAPCOREINFO*)info)->bmciColors; if (((const BITMAPCOREINFO*)info)->bmciHeader.bcBitCount != 1) return FALSE; - /* Check if the first color is black */ - if ((rgb->rgbtRed == 0) && (rgb->rgbtGreen == 0) && (rgb->rgbtBlue == 0)) + for (int i = 0; i < 2; i++) { - rgb++; - - /* Check if the second color is white */ - return ((rgb->rgbtRed == 0xff) && (rgb->rgbtGreen == 0xff) - && (rgb->rgbtBlue == 0xff)); + if ((rgb[i].rgbtRed == 0) && (rgb[i].rgbtGreen == 0) && (rgb[i].rgbtBlue == 0)) + found_black = TRUE; + if ((rgb[i].rgbtRed == 0xff) && (rgb[i].rgbtGreen == 0xff) && (rgb[i].rgbtBlue == 0xff)) + found_white = TRUE; } - else return FALSE; } else /* assume BITMAPINFOHEADER */ { @@ -138,18 +136,15 @@ static BOOL is_dib_monochrome( const BITMAPINFO* info ) if (info->bmiHeader.biBitCount != 1) return FALSE; - /* Check if the first color is black */ - if ((rgb->rgbRed == 0) && (rgb->rgbGreen == 0) && - (rgb->rgbBlue == 0) && (rgb->rgbReserved == 0)) + for (int i = 0; i < 2; i++) { - rgb++; - - /* Check if the second color is white */ - return ((rgb->rgbRed == 0xff) && (rgb->rgbGreen == 0xff) - && (rgb->rgbBlue == 0xff) && (rgb->rgbReserved == 0)); + if ((rgb[i].rgbRed == 0) && (rgb[i].rgbGreen == 0) && (rgb[i].rgbBlue == 0) && (rgb[i].rgbReserved == 0)) + found_black = TRUE; + if ((rgb[i].rgbRed == 0xff) && (rgb[i].rgbGreen == 0xff) && (rgb[i].rgbBlue == 0xff) && (rgb[i].rgbReserved == 0)) + found_white = TRUE; } - else return FALSE; } + return found_black && found_white; } static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse )