wayland: Fix initial fullscreen monitor support

-1 means that we have no specific preference for an initial
fullscreen monitor, and -1 is less than the number of monitors,
so we would end up accessing invalid memory. Prevent that.

https://bugzilla.gnome.org/show_bug.cgi?id=752875
This commit is contained in:
Giovanni Campagna
2015-07-25 17:22:41 -07:00
committed by Matthias Clasen
parent b2b4a3bb0a
commit 83b7a0f0e5

View File

@ -1001,7 +1001,8 @@ gdk_wayland_window_create_xdg_surface (GdkWindow *window)
const gchar *app_id;
GdkScreen *screen = gdk_window_get_screen (window);
struct wl_output *fullscreen_output = NULL;
if (impl->initial_fullscreen_monitor < gdk_screen_get_n_monitors (screen))
if (impl->initial_fullscreen_monitor >= 0 &&
impl->initial_fullscreen_monitor < gdk_screen_get_n_monitors (screen))
fullscreen_output = _gdk_wayland_screen_get_wl_output (screen, impl->initial_fullscreen_monitor);
impl->xdg_surface = xdg_shell_get_xdg_surface (display_wayland->xdg_shell, impl->surface);