Skip to content

Commit

Permalink
nemo-directory.c: Fix memory leak.
Browse files Browse the repository at this point in the history
When creating a new file or a new file from a template, it's possible
that file->details->is_added may not be TRUE, and cause this file to
not be finalized along with other files if the view directory is
destroyed.

This can cause issues when re-entering that directory, with the file
being in an undefined state, and could prevent the view from fully
loading the location.

The symptoms are similar to #2623

Fixes #2736
  • Loading branch information
mtwebster committed May 16, 2021
1 parent 44bc8a6 commit 73aafd8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions libnemo-private/nemo-directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,17 +977,21 @@ nemo_directory_notify_files_added (GList *files)
* to the directory by a nemo_file_get() but not gotten
* files_added emitted
*/
if (file && file->details->is_added) {
/* A file already exists, it was probably renamed.
* If it was renamed this could be ignored, but
* queue a change just in case */
nemo_file_changed (file);
nemo_file_unref (file);
} else {
hash_table_list_prepend (added_lists,
directory,
g_object_ref (location));
}
if (file != NULL) {
if (file->details->is_added) {
/* A file already exists, it was probably renamed
* If it was renamed this could be ignored, but
* queue a change just in case */
nemo_file_changed (file);
} else {
hash_table_list_prepend (added_lists,
directory,
g_object_ref (location));
}

nemo_file_unref (file);
}

nemo_directory_unref (directory);
}

Expand Down

0 comments on commit 73aafd8

Please sign in to comment.