Skip to content

Commit c3f954f

Browse files
author
smpl-os
committed
fix(nemo-file): keep ref alive through nemo_file_clear_info, not just remove_file
1 parent e1dae6b commit c3f954f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

libnemo-private/nemo-file.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8183,18 +8183,18 @@ nemo_file_mark_gone (NemoFile *file)
81838183

81848184
/* Let the directory know it's gone. */
81858185
directory = file->details->directory;
8186+
/* Hold a temporary ref so the object stays alive through both
8187+
* nemo_directory_remove_file() (which may drop the last directory ref
8188+
* and free the object) AND the nemo_file_clear_info() call below.
8189+
* Without this, remove_file can free the NemoFile and clear_info then
8190+
* dereferences the freed pointer, causing a SIGSEGV (bug #3712). */
8191+
nemo_file_ref (file);
81868192
if (!nemo_file_is_self_owned (file)) {
8187-
/* Hold a temporary ref across nemo_directory_remove_file: if the
8188-
* directory is monitoring its file list, remove_file calls
8189-
* nemo_file_unref() which may drop the refcount to zero and free
8190-
* the object right here — leaving a dangling pointer for the
8191-
* nemo_file_clear_info() call below (bug #3712). */
8192-
nemo_file_ref (file);
81938193
nemo_directory_remove_file (directory, file);
8194-
nemo_file_unref (file);
81958194
}
81968195

81978196
nemo_file_clear_info (file);
8197+
nemo_file_unref (file);
81988198

81998199
/* FIXME bugzilla.gnome.org 42429:
82008200
* Maybe we can get rid of the name too eventually, but

0 commit comments

Comments
 (0)