-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Description:
In win32_window.cpp.cpp, the WndProc function relies on WM_NCCREATE to set the GWLP_USERDATA pointer to the Win32Window instance. Later messages call GetThisFromHandle(window), which dereferences this pointer:
else if (Win32Window* that = GetThisFromHandle(window)) {
return that->MessageHandler(window, message, wparam, lparam);
}
Potential Issue:
If a message arrives before WM_NCCREATE is processed, GWLP_USERDATA will be nullptr. This can result in undefined behaviour or a crash when dereferencing the pointer. This could happen in rare circumstances, depending on the Windows message queue timing.
Suggested Fix:
Safely check if GetThisFromHandle(window) returns nullptr before dereferencing.
Example:
Win32Window* that = GetThisFromHandle(window);
if (that) {
return that->MessageHandler(window, message, wparam, lparam);
}
This ensures the window procedure does not attempt to access an uninitialized pointer.
Severity: Critical – could crash the app.