From 95defd662038feaa5c97d4f4ab2c9c2a9eba8c89 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 17 Jan 2017 21:18:31 -0800 Subject: [PATCH] Use icon width * sizeof(Uint32) instead of icon pitch when copying to icon resource data --- src/video/windows/SDL_windowswindow.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 531010e0e..0cb2a01ad 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -409,7 +409,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) SDL_RWops *dst; /* Create temporary bitmap buffer */ - icon_len = 40 + icon->h * icon->w * 4; + icon_len = 40 + icon->h * icon->w * sizeof(Uint32); icon_bmp = SDL_stack_alloc(BYTE, icon_len); dst = SDL_RWFromMem(icon_bmp, icon_len); if (!dst) { @@ -424,7 +424,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) SDL_WriteLE16(dst, 1); SDL_WriteLE16(dst, 32); SDL_WriteLE32(dst, BI_RGB); - SDL_WriteLE32(dst, icon->h * icon->w * 4); + SDL_WriteLE32(dst, icon->h * icon->w * sizeof(Uint32)); SDL_WriteLE32(dst, 0); SDL_WriteLE32(dst, 0); SDL_WriteLE32(dst, 0); @@ -435,7 +435,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) y = icon->h; while (y--) { Uint8 *src = (Uint8 *) icon->pixels + y * icon->pitch; - SDL_RWwrite(dst, src, icon->pitch, 1); + SDL_RWwrite(dst, src, icon->w * sizeof(Uint32), 1); } hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);