# SDL: avoid UB (left shift of negative number) in SDL\_windowsevents.c

**URL:** <https://discourse.libsdl.org/t/sdl-avoid-ub-left-shift-of-negative-number-in-sdl-windowsevents-c/58457>\
**Category:** SDL Commits\
**Created:** [March 10, 2025, 4:09pm UTC](https://discourse.libsdl.org/t/sdl-avoid-ub-left-shift-of-negative-number-in-sdl-windowsevents-c/58457 "2025-03-10T16:09:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [March 10, 2025, 4:09pm UTC](https://discourse.libsdl.org/t/sdl-avoid-ub-left-shift-of-negative-number-in-sdl-windowsevents-c/58457/1 "2025-03-10T16:09:49Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/f1d16e9b4dcc8bfac5fe13b22b16d6552b1fcf79>

```diff
From f1d16e9b4dcc8bfac5fe13b22b16d6552b1fcf79 Mon Sep 17 00:00:00 2001
From: rohlem <[EMAIL REDACTED]>
Date: Mon, 10 Mar 2025 16:23:06 +0100
Subject: [PATCH] avoid UB (left shift of negative number) in
 SDL_windowsevents.c

---
 src/video/windows/SDL_windowsevents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index f271db85b828e..94997c151bc69 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1640,7 +1640,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
             POINT cursorPos;
             GetCursorPos(&cursorPos);
             ScreenToClient(hwnd, &cursorPos);
- PostMessage(hwnd, WM_MOUSEMOVE, 0, cursorPos.x | cursorPos.y << 16);
+ PostMessage(hwnd, WM_MOUSEMOVE, 0, cursorPos.x | (((unsigned int)((short)cursorPos.y)) << 16));
         }
     } break;
 

```
