diff options
author | Ondrej Holy <oholy@redhat.com> | 2023-01-26 13:20:51 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2023-04-06 10:40:31 +0200 |
commit | b21e7564e0bc522cd19656de314c02e8a376d8f4 (patch) | |
tree | 102f14ffda6f897f1483eea92d00dae036d7c310 | |
parent | 247dda2cc30663b7e91f8a2169fb952f45b97667 (diff) | |
download | nautilus-b21e7564e0bc522cd19656de314c02e8a376d8f4.tar.gz |
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.
-rw-r--r-- | src/nautilus-file-utilities.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c index efe42a09c..ea24367ad 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; |