From fd703e98e4add03bf5c5fa0ce6584893594f4add Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Tue, 16 Nov 2021 00:22:45 +0000 Subject: [PATCH] glfw: update setIcon hotfix for undefined behavior See https://github.com/GLFW/glfw/pull/1986 Signed-off-by: Stephen Gutekanst --- glfw/upstream/glfw/src/x11_window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/glfw/upstream/glfw/src/x11_window.c b/glfw/upstream/glfw/src/x11_window.c index 5fdf7819..85d2da44 100644 --- a/glfw/upstream/glfw/src/x11_window.c +++ b/glfw/upstream/glfw/src/x11_window.c @@ -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++) { @@ -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); } }