[nautilus/wip/apoos-maximus/gsoc2020: 18/29] properties-window: Clear list of dangling pointers
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/apoos-maximus/gsoc2020: 18/29] properties-window: Clear list of dangling pointers
- Date: Wed, 5 Aug 2020 13:48:12 +0000 (UTC)
commit d41531303695f0451a2df4472e71ab5953cf5b50
Author: António Fernandes <antoniof gnome org>
Date: Sat Jul 4 21:51:53 2020 +0100
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.
src/nautilus-properties-window.c | 2 ++
1 file changed, 2 insertions(+)
---
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));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]