diff options
author | Alexander Schwinn <acs82@gmx.de> | 2018-02-12 00:27:41 +0100 |
---|---|---|
committer | Alexander Schwinn <acs82@gmx.de> | 2018-02-12 00:27:41 +0100 |
commit | 2da1b2afd197d65be07560c6db35cc27686090e7 (patch) | |
tree | e3ac2adecbbc68acf6834b49b911fba71d655486 /thunar | |
parent | fa9d63534d553ff05bd9aed7eef0fc700156f944 (diff) | |
download | thunar-2da1b2afd197d65be07560c6db35cc27686090e7.tar.gz |
Crash in thunar_file_is_gfile_ancestor (bug #14202)
Diffstat (limited to 'thunar')
-rw-r--r-- | thunar/thunar-file.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 46d0dc72..f70e5ada 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2809,25 +2809,31 @@ gboolean thunar_file_is_gfile_ancestor (const ThunarFile *file, GFile *ancestor) { - gboolean is_ancestor = FALSE; GFile *current = NULL; GFile *tmp; _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); + _thunar_return_val_if_fail (G_IS_FILE (file->gfile), FALSE); _thunar_return_val_if_fail (G_IS_FILE (ancestor), FALSE); - for (current = g_object_ref (file->gfile); - is_ancestor == FALSE && current != NULL; - tmp = g_file_get_parent (current), g_object_unref (current), current = tmp) + current = g_object_ref (file->gfile); + while(TRUE) { + tmp = g_file_get_parent (current); + g_object_unref (current); + current = tmp; + + if (current == NULL) /* parent of root is NULL */ + return FALSE; + if (G_UNLIKELY (g_file_equal (current, ancestor))) - is_ancestor = TRUE; + { + g_object_unref (current); + return TRUE; + } } - if (current != NULL) - g_object_unref (current); - - return is_ancestor; + return FALSE; } |