[mutter] color-device: Don't attempt to set GAMMA_LUT if LUT size is zero
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] color-device: Don't attempt to set GAMMA_LUT if LUT size is zero
- Date: Sat, 3 Sep 2022 15:05:49 +0000 (UTC)
commit 255cd9a9fff5d928eb63eb3464b5d4c27a2a74e4
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Sat Sep 3 15:01:40 2022 +0200
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>
src/backends/meta-color-device.c | 14 +++++++++-----
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 272fade579..e6854fc3a6 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 573acadb86..82c235b0f4 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]