summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-03-13 16:00:19 +0100
committerMarco Trevisan (TreviƱo) <mail@3v1n0.net>2018-07-18 00:57:57 +0200
commita056ddc904b8540a3e8d1abbb4ae1de6950a6971 (patch)
tree67888dab224f4898088a44b3a6748b282b22f462
parentb109d6307534136c61d174a3b6ed55357ce0e0e3 (diff)
downloadnautilus-a056ddc904b8540a3e8d1abbb4ae1de6950a6971.tar.gz
file: guard against recursive links when emitting change signals
Currently, when propagating file changes, the code recursively notifies the files that link to the original file. This quickly falls apart with recursive links, as a stack overflow occurs. The fix is only partial, however, in that if you try a bit harder, you can still crash Nautilus by throwing in another file into the loop (hah). Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/289
-rw-r--r--src/nautilus-file.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 37f189f8c..5865c3229 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -8581,10 +8581,29 @@ nautilus_file_emit_changed (NautilusFile *file)
link_files = get_link_files (file);
for (p = link_files; p != NULL; p = p->next)
{
- if (p->data != file)
+ /* Looking for directly recursive links. */
+ g_autolist (NautilusFile) link_targets = NULL;
+ NautilusDirectory *directory;
+
+ if (p->data == file)
+ {
+ continue;
+ }
+
+ link_targets = get_link_files (p->data);
+ directory = nautilus_file_get_directory (p->data);
+
+ /* Reiterating (heh) that this will break with more complex cycles.
+ * Users, stop trying to break things on purpose.
+ */
+ if (g_list_find (link_targets, file) != NULL &&
+ directory == nautilus_file_get_directory (file))
{
- nautilus_file_changed (NAUTILUS_FILE (p->data));
+ g_signal_emit (p->data, signals[CHANGED], 0, p->data);
+ continue;
}
+
+ nautilus_file_changed (NAUTILUS_FILE (p->data));
}
nautilus_file_list_free (link_files);
}