Blob Blame History Raw
From c07364d65d3e6353076b02c97ce63dfe00aaedc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Thu, 25 Jul 2019 01:21:28 +0200
Subject: [PATCH 24/28] monitor-config-migration: Free the output key on
 invalid spec

In create_monitor_config we assume that we take the ownership of the output_key
values, however if we have an early return because an invalid spec is set, we
don't free it.

So cleanup it on failure, as it happens for other cases.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
---
 src/backends/meta-monitor-config-migration.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/backends/meta-monitor-config-migration.c b/src/backends/meta-monitor-config-migration.c
index ed6c80184..26393ef02 100644
--- a/src/backends/meta-monitor-config-migration.c
+++ b/src/backends/meta-monitor-config-migration.c
@@ -655,60 +655,61 @@ load_config_file (GFile   *file,
       g_free (parser.output_field);
       g_hash_table_destroy (parser.configs);
 
       return NULL;
     }
 
   return parser.configs;
 }
 
 static MetaMonitorConfig *
 create_monitor_config (MetaOutputKey    *output_key,
                        MetaOutputConfig *output_config,
                        int               mode_width,
                        int               mode_height,
                        GError          **error)
 {
   MetaMonitorModeSpec *mode_spec;
   MetaMonitorSpec *monitor_spec;
   MetaMonitorConfig *monitor_config;
 
   mode_spec = g_new0 (MetaMonitorModeSpec, 1);
   *mode_spec = (MetaMonitorModeSpec) {
     .width = mode_width,
     .height = mode_height,
     .refresh_rate = output_config->refresh_rate
   };
 
   if (!meta_verify_monitor_mode_spec (mode_spec, error))
     {
       g_free (mode_spec);
+      free_output_key (output_key);
       return NULL;
     }
 
   monitor_spec = g_new0 (MetaMonitorSpec, 1);
   *monitor_spec = (MetaMonitorSpec) {
     .connector = output_key->connector,
     .vendor = output_key->vendor,
     .product = output_key->product,
     .serial = output_key->serial
   };
 
   monitor_config = g_new0 (MetaMonitorConfig, 1);
   *monitor_config = (MetaMonitorConfig) {
     .monitor_spec = monitor_spec,
     .mode_spec = mode_spec,
     .enable_underscanning = output_config->is_underscanning
   };
 
   if (!meta_verify_monitor_config (monitor_config, error))
     {
       meta_monitor_config_free (monitor_config);
       return NULL;
     }
 
   return monitor_config;
 }
 
 typedef struct _MonitorTile
 {
   MetaOutputKey *output_key;
-- 
2.26.2