You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
11 months ago
|
From e03d731e3dcb8d0f52ffbc6faa188802b742d1e9 Mon Sep 17 00:00:00 2001
|
||
|
From: Ondrej Holy <oholy@redhat.com>
|
||
|
Date: Thu, 26 Jan 2023 13:20:51 +0100
|
||
|
Subject: [PATCH] file-utilities: Prevent passing NULL to g_object_unref
|
||
|
|
||
|
The `nautilus_find_existing_uri_in_hierarchy` function calls the
|
||
|
`g_object_unref` with a `NULL` pointer when `g_file_query_info` fails.
|
||
|
This leads to a crash e.g. when parent directory of the currently
|
||
|
opened location is removed. Let's port the code to use `g_autoptr` to
|
||
|
avoid that.
|
||
|
---
|
||
|
src/nautilus-file-utilities.c | 4 ++--
|
||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
|
||
|
index e8f1ca2fb..1c913dbad 100644
|
||
|
--- a/src/nautilus-file-utilities.c
|
||
|
+++ b/src/nautilus-file-utilities.c
|
||
|
@@ -598,7 +598,6 @@ nautilus_generate_unique_file_in_directory (GFile *directory,
|
||
|
GFile *
|
||
|
nautilus_find_existing_uri_in_hierarchy (GFile *location)
|
||
|
{
|
||
|
- GFileInfo *info;
|
||
|
GFile *tmp;
|
||
|
|
||
|
g_assert (location != NULL);
|
||
|
@@ -606,10 +605,11 @@ nautilus_find_existing_uri_in_hierarchy (GFile *location)
|
||
|
location = g_object_ref (location);
|
||
|
while (location != NULL)
|
||
|
{
|
||
|
+ g_autoptr (GFileInfo) info = NULL;
|
||
|
+
|
||
|
info = g_file_query_info (location,
|
||
|
G_FILE_ATTRIBUTE_STANDARD_NAME,
|
||
|
0, NULL, NULL);
|
||
|
- g_object_unref (info);
|
||
|
if (info != NULL)
|
||
|
{
|
||
|
return location;
|
||
|
--
|
||
|
2.40.0
|
||
|
|