monitor-config: Free meta_monitor_spec safely

`g_free()` alone can't help if the value it gets is `NULL` + the offset
of the struct members.

This prevents gnome-shell from segfaulting if `monitors.xml` contains
invalid XML.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
This commit is contained in:
Thomas Mühlbacher 2021-01-27 20:00:04 +01:00 committed by Marge Bot
parent 70cdd72040
commit 88647ae23c

View File

@ -1388,7 +1388,8 @@ meta_monitor_config_manager_class_init (MetaMonitorConfigManagerClass *klass)
void
meta_monitor_config_free (MetaMonitorConfig *monitor_config)
{
meta_monitor_spec_free (monitor_config->monitor_spec);
if (monitor_config->monitor_spec)
meta_monitor_spec_free (monitor_config->monitor_spec);
g_free (monitor_config->mode_spec);
g_free (monitor_config);
}