glfw: hot patch undefined behavior in GLFW that went unnoticed 6+ years

Upstream pull request: https://github.com/glfw/glfw/pull/1986

Article: https://devlog.hexops.com/2021/perfecting-glfw-for-zig-and-finding-undefined-behavior

Fixes hexops/mach#20

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-10-31 11:50:09 -07:00
parent 93110e82ca
commit 9bc9984930
2 changed files with 33 additions and 34 deletions

View file

@ -2133,10 +2133,10 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
for (j = 0; j < images[i].width * images[i].height; j++)
{
*target++ = (images[i].pixels[j * 4 + 0] << 16) |
(images[i].pixels[j * 4 + 1] << 8) |
(images[i].pixels[j * 4 + 2] << 0) |
(images[i].pixels[j * 4 + 3] << 24);
*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);
}
}