src/video/wayland/SDL_waylandwindow.c
changeset 11088 69452f9839d5
parent 10737 3406a0f8b041
child 11092 9c9b7b7e46e1
     1.1 --- a/src/video/wayland/SDL_waylandwindow.c	Sat Jun 10 15:38:14 2017 -0400
     1.2 +++ b/src/video/wayland/SDL_waylandwindow.c	Sun Jun 11 00:50:26 2017 -0400
     1.3 @@ -129,6 +129,24 @@
     1.4  Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
     1.5  {
     1.6      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     1.7 +    const Uint32 version = ((((Uint32) info->version.major) * 1000000) +
     1.8 +                            (((Uint32) info->version.minor) * 10000) +
     1.9 +                            (((Uint32) info->version.patch)));
    1.10 +
    1.11 +    /* Before 2.0.6, it was possible to build an SDL with Wayland support
    1.12 +       (SDL_SysWMinfo will be large enough to hold Wayland info), but build
    1.13 +       your app against SDL headers that didn't have Wayland support
    1.14 +       (SDL_SysWMinfo could be smaller than Wayland needs. This would lead
    1.15 +       to an app properly using SDL_GetWindowWMInfo() but we'd accidentally
    1.16 +       overflow memory on the stack or heap. To protect against this, we've
    1.17 +       padded out the struct unconditionally in the headers and Wayland will
    1.18 +       just return an error for older apps using this function. Those apps
    1.19 +       will need to be recompiled against newer headers or not use Wayland,
    1.20 +       maybe by forcing SDL_VIDEODRIVER=x11. */
    1.21 +    if (version < 2000006) {
    1.22 +        info->subsystem = SDL_SYSWM_UNKNOWN;
    1.23 +        return SDL_FALSE;
    1.24 +    }
    1.25  
    1.26      info->info.wl.display = data->waylandData->display;
    1.27      info->info.wl.surface = data->surface;