diff options
author | Jonas Ã…dahl <jadahl@gmail.com> | 2022-09-03 15:01:40 +0200 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2022-09-03 14:41:36 +0000 |
commit | 255cd9a9fff5d928eb63eb3464b5d4c27a2a74e4 (patch) | |
tree | b539424c355b72c10c07be0a7084097e92f9bd79 | |
parent | 1bd06e645e8c85df78dcc3889abf13d4f31db453 (diff) | |
download | mutter-255cd9a9fff5d928eb63eb3464b5d4c27a2a74e4.tar.gz |
color-device: Don't attempt to set GAMMA_LUT if LUT size is zero
This might happen on e.g. virtual machines. If we don't skip trying,
we'll end up crashing because we'll fail to create a look up table since
the size must be greater than zero to make any sense.
Fixes: baef39e603f232f5ce3c2ce79c443383cd6a1f67
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2415
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
-rw-r--r-- | src/backends/meta-color-device.c | 14 | ||||
-rw-r--r-- | src/backends/meta-color-profile.c | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/backends/meta-color-device.c b/src/backends/meta-color-device.c index 272fade57..e6854fc3a 100644 --- a/src/backends/meta-color-device.c +++ b/src/backends/meta-color-device.c @@ -1171,7 +1171,6 @@ meta_color_device_update (MetaColorDevice *color_device, MetaColorProfile *color_profile; MetaMonitor *monitor; size_t lut_size; - g_autoptr (MetaGammaLut) lut = NULL; color_profile = meta_color_device_get_assigned_profile (color_device); if (!color_profile) @@ -1206,11 +1205,16 @@ meta_color_device_update (MetaColorDevice *color_device, } lut_size = meta_monitor_get_gamma_lut_size (monitor); - lut = meta_color_profile_generate_gamma_lut (color_profile, - temperature, - lut_size); + if (lut_size > 0) + { + g_autoptr (MetaGammaLut) lut = NULL; + + lut = meta_color_profile_generate_gamma_lut (color_profile, + temperature, + lut_size); - meta_monitor_set_gamma_lut (monitor, lut); + meta_monitor_set_gamma_lut (monitor, lut); + } g_signal_emit (color_device, signals[UPDATED], 0); } diff --git a/src/backends/meta-color-profile.c b/src/backends/meta-color-profile.c index 573acadb8..82c235b0f 100644 --- a/src/backends/meta-color-profile.c +++ b/src/backends/meta-color-profile.c @@ -488,7 +488,7 @@ meta_color_profile_generate_gamma_lut (MetaColorProfile *color_profile, unsigned int temperature, size_t lut_size) { - g_return_val_if_fail (lut_size > 0, NULL); + g_assert (lut_size > 0); if (color_profile->calibration->has_vcgt) { |