secret-paths: Fix memleak when unlocking a path

A GPtrArray allocated to temporarily hold (un)locked item paths was
not freed when the collection has a non-empty D-Bus path.

Signed-off-by: Daiki Ueno <dueno@src.gnome.org>
This commit is contained in:
Daiki Ueno 2023-10-18 16:03:21 +09:00
parent 115474aa67
commit e9818571e3

View File

@ -1044,7 +1044,6 @@ on_xlock_called (GObject *source,
XlockClosure *closure = g_task_get_task_data (task); XlockClosure *closure = g_task_get_task_data (task);
GCancellable *cancellable = g_task_get_cancellable (task); GCancellable *cancellable = g_task_get_cancellable (task);
SecretService *self = SECRET_SERVICE (g_task_get_source_object (task)); SecretService *self = SECRET_SERVICE (g_task_get_source_object (task));
GPtrArray *xlocked_array;
const gchar *prompt = NULL; const gchar *prompt = NULL;
gchar **xlocked = NULL; gchar **xlocked = NULL;
GError *error = NULL; GError *error = NULL;
@ -1056,11 +1055,13 @@ on_xlock_called (GObject *source,
g_task_return_error (task, g_steal_pointer (&error)); g_task_return_error (task, g_steal_pointer (&error));
} else { } else {
xlocked_array = g_ptr_array_new_with_free_func (g_free);
g_variant_get (retval, "(^ao&o)", &xlocked, &prompt); g_variant_get (retval, "(^ao&o)", &xlocked, &prompt);
if (_secret_util_empty_path (prompt)) { if (_secret_util_empty_path (prompt)) {
GPtrArray *xlocked_array;
xlocked_array = g_ptr_array_new_with_free_func (g_free);
for (i = 0; xlocked[i]; i++) for (i = 0; xlocked[i]; i++)
g_ptr_array_add (xlocked_array, g_strdup (xlocked[i])); g_ptr_array_add (xlocked_array, g_strdup (xlocked[i]));