From e7a88dc6b2eed37d513cf33396d6cf35e8a049cc Mon Sep 17 00:00:00 2001 From: Marek Chalupa Date: Tue, 15 Dec 2015 17:47:12 +0100 Subject: [PATCH] meta-launcher: don't call g_object_unref() on NULL g_object_unref() was called no matter what we got for value https://bugzilla.gnome.org/show_bug.cgi?id=760670 --- src/backends/native/meta-launcher.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c index 34480cdc2..7cd338b16 100644 --- a/src/backends/native/meta-launcher.c +++ b/src/backends/native/meta-launcher.c @@ -295,7 +295,7 @@ get_primary_gpu_path (const gchar *seat_name) if (!devices) goto out; - for (tmp = devices; tmp != NULL && path == NULL; tmp = tmp->next) + for (tmp = devices; tmp != NULL; tmp = tmp->next) { GUdevDevice *platform_device = NULL, *pci_device = NULL; GUdevDevice *dev = tmp->data; @@ -325,13 +325,15 @@ get_primary_gpu_path (const gchar *seat_name) continue; platform_device = g_udev_device_get_parent_with_subsystem (dev, "platform", NULL); - pci_device = g_udev_device_get_parent_with_subsystem (dev, "pci", NULL); - if (platform_device != NULL) { path = g_strdup (g_udev_device_get_device_file (dev)); + g_object_unref (platform_device); + break; } - else if (pci_device != NULL) + + pci_device = g_udev_device_get_parent_with_subsystem (dev, "pci", NULL); + if (pci_device != NULL) { /* get value of boot_vga attribute or 0 if the device has no boot_vga */ boot_vga = g_udev_device_get_sysfs_attr_as_int (pci_device, "boot_vga"); @@ -339,11 +341,11 @@ get_primary_gpu_path (const gchar *seat_name) { /* found the boot_vga device */ path = g_strdup (g_udev_device_get_device_file (dev)); + break; } - } - g_object_unref (platform_device); - g_object_unref (pci_device); + g_object_unref (pci_device); + } } g_list_free_full (devices, g_object_unref);