monitor: Allow %NULL mode in calculate_mode_scale()

If no global scaling factor has been set, we currently segfault when
called with a %NULL mode parameter, which happens when calculating the
scale for the current mode while no modes are available.

Adding %NULL checks in the corresponding callers would mean that we'd
have to duplicate the global scaling factor handling, so instead consider
%NULL mode parameters valid and handle them gracefully.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/41
This commit is contained in:
Florian Müllner 2018-03-08 20:12:54 +01:00
parent 675d429ba0
commit e977d65244

View File

@ -1458,6 +1458,9 @@ calculate_scale (MetaMonitor *monitor,
scale = 1.0; scale = 1.0;
if (monitor_mode == NULL)
goto out;
meta_monitor_mode_get_resolution (monitor_mode, meta_monitor_mode_get_resolution (monitor_mode,
&resolution_width, &resolution_width,
&resolution_height); &resolution_height);