BUGFIXING: always initialize csr_bmp fields with explicit assignments

This commit is contained in:
Vincent Wei
2020-01-03 14:38:28 +08:00
parent 2f85645e9d
commit 239924c63e
3 changed files with 14 additions and 13 deletions

View File

@@ -370,9 +370,7 @@ HCURSOR GUIAPI GetDefaultCursor (void)
return def_cursor;
}
static BITMAP csr_bmp = {
BMP_TYPE_NORMAL, 0, 0, 0, 0, CURSORWIDTH, CURSORHEIGHT
};
static BITMAP csr_bmp;
BOOL mg_InitCursor (void)
{
@@ -392,10 +390,14 @@ BOOL mg_InitCursor (void)
CSR_OLDBOXTOP = -100;
}
/* always initialize fields by explicitly assignments */
csr_bmp.bmType = BMP_TYPE_NORMAL;
csr_bmp.bmBitsPerPixel = __gal_screen->format->BitsPerPixel;
csr_bmp.bmBytesPerPixel = __gal_screen->format->BytesPerPixel;
csr_bmp.bmWidth = CURSORWIDTH;
csr_bmp.bmHeight = CURSORHEIGHT;
csr_bmp.bmPitch = __gal_screen->format->BytesPerPixel * CURSORWIDTH;
return TRUE;
}

View File

@@ -108,9 +108,7 @@ HCURSOR GUIAPI LoadCursorFromMem (const void* area)
return load_cursor_from_mem (area);
}
static BITMAP csr_bmp = {
BMP_TYPE_NORMAL, 0, 0, 0, 0, CURSORWIDTH, CURSORHEIGHT
};
static BITMAP csr_bmp;
/* Only called from InitCursor and client code. */
HCURSOR GUIAPI CreateCursor(int xhotspot, int yhotspot, int w, int h,
@@ -242,6 +240,10 @@ BOOL mg_InitCursor(void)
csrimgsize = GAL_GetBoxSize (__gal_screen, CURSORWIDTH, CURSORHEIGHT, &csrimgpitch);
/* always initialize fields by explicitly assignments */
csr_bmp.bmType = BMP_TYPE_NORMAL;
csr_bmp.bmWidth = CURSORWIDTH;
csr_bmp.bmHeight = CURSORHEIGHT;
csr_bmp.bmBitsPerPixel = __gal_screen->format->BitsPerPixel;
csr_bmp.bmBytesPerPixel = __gal_screen->format->BytesPerPixel;
csr_bmp.bmPitch = csrimgpitch;

View File

@@ -139,9 +139,7 @@ HCURSOR GUIAPI LoadCursorFromMem (const void* area)
return load_cursor_from_mem (area);
}
static BITMAP csr_bmp = {
BMP_TYPE_NORMAL, 0, 0, 0, 0, CURSORWIDTH, CURSORHEIGHT
};
static BITMAP csr_bmp;
/* Only called from InitCursor and client code. */
HCURSOR GUIAPI CreateCursor(int xhotspot, int yhotspot, int w, int h,
@@ -279,11 +277,10 @@ BOOL realInitCursor(void)
&csrimgpitch);
csr_bmp.bmType = BMP_TYPE_NORMAL;
csr_bmp.bmWidth = CURSORWIDTH;
csr_bmp.bmHeight = CURSORHEIGHT;
csr_bmp.bmBitsPerPixel = __gal_screen->format->BitsPerPixel;
csr_bmp.bmBytesPerPixel = __gal_screen->format->BytesPerPixel;
csr_bmp.bmWidth = CURSORWIDTH;
csr_bmp.bmHeight = CURSORHEIGHT;
csr_bmp.bmPitch = csrimgpitch;
if( !(savedbits = malloc(csrimgsize)) )