Skip to content

Commit

Permalink
glfw: update setIcon hotfix for undefined behavior
Browse files Browse the repository at this point in the history
See glfw/glfw#1986

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
  • Loading branch information
slimsag committed Nov 16, 2021
1 parent de499c2 commit b967fd5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions upstream/glfw/src/x11_window.c
Expand Up @@ -2123,8 +2123,8 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
for (i = 0; i < count; i++)
longCount += 2 + images[i].width * images[i].height;

long* icon = calloc(longCount, sizeof(long));
long* target = icon;
unsigned long* icon = calloc(longCount, sizeof(unsigned long));
unsigned long* target = icon;

for (i = 0; i < count; i++)
{
Expand All @@ -2133,10 +2133,10 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,

for (j = 0; j < images[i].width * images[i].height; j++)
{
*target++ = (((long)images[i].pixels[j * 4 + 0]) << 16) |
(((long)images[i].pixels[j * 4 + 1]) << 8) |
(((long)images[i].pixels[j * 4 + 2]) << 0) |
(((long)images[i].pixels[j * 4 + 3]) << 24);
*target++ = (((unsigned long)images[i].pixels[j * 4 + 0]) << 16) |
(((unsigned long)images[i].pixels[j * 4 + 1]) << 8) |
(((unsigned long)images[i].pixels[j * 4 + 2]) << 0) |
(((unsigned long)images[i].pixels[j * 4 + 3]) << 24);
}
}

Expand Down

0 comments on commit b967fd5

Please sign in to comment.