summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2020-07-04 21:51:53 +0100
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2020-08-05 13:48:10 +0000
commitd41531303695f0451a2df4472e71ab5953cf5b50 (patch)
treeaf11454be3e11aea08036b8f3aec289ae7ed69dc
parent1d60b2dd4b267718fe9afe73bc16cc26b51584d8 (diff)
downloadnautilus-d41531303695f0451a2df4472e71ab5953cf5b50.tar.gz
properties-window: Clear list of dangling pointers
The window->change_permission_combos list is populated each time the "Change Permissions of Enclosed Files" button is clicked. This list is cleared when the Properties window is destroyed, but not when the "Change Permissions of Enclosed Files" dialog is. As a result, if the button is clicked again, new combos are prepended to the list but the previous (now-dangling) pointers are still there. If GLib is built without -DG_DISABLE_CAST_CHECKS, then trying to use this dialog a second time to change permissions of enclosed files will result in a crash due to the dangling pointers failing a cast check. But even though production code will not crash this way, leaving dangling pointers in the list is a bad idea. Before this dialog was ported to a GtkBuilder UI definition, this bug was masked by a leak of floating references. To properly manage the lifecycle of this list, let's clear it whenever the dialog is destroyed.
-rw-r--r--src/nautilus-properties-window.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index afea0c3c8..a9bafc8b2 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -4450,6 +4450,7 @@ on_change_permissions_response (GtkDialog *dialog,
if (response != GTK_RESPONSE_OK)
{
+ g_clear_pointer (&window->change_permission_combos, g_list_free);
gtk_widget_destroy (GTK_WIDGET (dialog));
return;
}
@@ -4527,6 +4528,7 @@ on_change_permissions_response (GtkDialog *dialog,
g_free (uri);
}
}
+ g_clear_pointer (&window->change_permission_combos, g_list_free);
gtk_widget_destroy (GTK_WIDGET (dialog));
}