https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1cad26ad08b70dea9bc63e49efe9d8509f2e08e7

commit 1cad26ad08b70dea9bc63e49efe9d8509f2e08e7
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Wed Jan 26 08:14:59 2022 +0900
Commit:     Katayama Hirofumi MZ <[email protected]>
CommitDate: Wed Jan 26 08:14:59 2022 +0900

    [USER32] Fix uninitialized cbTotal
    
    CORE-18025
---
 win32ss/user/user32/misc/exticon.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/win32ss/user/user32/misc/exticon.c 
b/win32ss/user/user32/misc/exticon.c
index 587a32a297f..09074c5c6a4 100644
--- a/win32ss/user/user32/misc/exticon.c
+++ b/win32ss/user/user32/misc/exticon.c
@@ -532,27 +532,26 @@ static UINT ICO_ExtractIconExW(
                             cbColorTable = (1 << bi.biBitCount) * 
sizeof(RGBTRIPLE);
                         }
                     }
+
+                    /* biSizeImage is the size of the raw bitmap data.
+                     * https://en.wikipedia.org/wiki/BMP_file_format */
+                    if (bi.biSizeImage == 0)
+                    {
+                         /* Calculate image size */
+#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
+                        bi.biSizeImage = WIDTHBYTES(bi.biWidth, bi.biBitCount) 
* (bi.biHeight / 2);
+                        bi.biSizeImage += WIDTHBYTES(bi.biWidth, 1) * 
(bi.biHeight / 2);
+#undef WIDTHBYTES
+                    }
+
+                    /* Calculate total size */
+                    cbTotal = bi.biSize + cbColorTable + bi.biSizeImage;
 #else
                     entry = (LPICONIMAGE)(imageData);
 #endif
 
                     if(sig == 2)
                     {
-#ifdef __REACTOS__
-                        /* biSizeImage is the size of the raw bitmap data.
-                         * A dummy 0 can be given for BI_RGB bitmaps.
-                         * https://en.wikipedia.org/wiki/BMP_file_format */
-                        if (bi.biSizeImage == 0 || bi.biSize == 
sizeof(BITMAPCOREHEADER))
-                        {
-                             /* Calculate image size */
-#define WIDTHBYTES(width, bits) (((width) * (bits) + 31) / 32 * 4)
-                            bi.biSizeImage = WIDTHBYTES(bi.biWidth, 
bi.biBitCount) * (bi.biHeight / 2);
-                            bi.biSizeImage += WIDTHBYTES(bi.biWidth, 1) * 
(bi.biHeight / 2);
-#undef WIDTHBYTES
-                        }
-                        /* Calculate total size */
-                        cbTotal = bi.biSize + cbColorTable + bi.biSizeImage;
-#endif
                         /* we need to prepend the bitmap data with hot spots 
for CreateIconFromResourceEx */
 #ifdef __REACTOS__
                         cursorData = HeapAlloc(GetProcessHeap(), 0, 2 * 
sizeof(WORD) + cbTotal);

Reply via email to