[glib/wip/gcleanup] gsubprocess: Fix a number of leaks and a segfault
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup] gsubprocess: Fix a number of leaks and a segfault
- Date: Sun, 10 Nov 2013 21:37:28 +0000 (UTC)
commit d5e8847c85608ce33c7675028f629bb7bc6de13c
Author: Stef Walter <stefw gnome org>
Date: Sat Nov 9 08:51:41 2013 +0100
gsubprocess: Fix a number of leaks and a segfault
Fixed a number of leaks in gsubprocess, as well as a segfault
that was hidden by never calling g_subprocess_communicate_state_free().
https://bugzilla.gnome.org/show_bug.cgi?id=711803
gio/gsubprocess.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index cafbcbb..ca9b006 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -405,6 +405,7 @@ g_subprocess_exited (GPid pid,
while (tasks)
{
g_task_return_boolean (tasks->data, TRUE);
+ g_object_unref (tasks->data);
tasks = g_slist_delete_link (tasks, tasks);
}
@@ -597,7 +598,7 @@ g_subprocess_finalize (GObject *object)
g_clear_object (&self->stdin_pipe);
g_clear_object (&self->stdout_pipe);
g_clear_object (&self->stderr_pipe);
- g_free (self->argv);
+ g_strfreev (self->argv);
G_OBJECT_CLASS (g_subprocess_parent_class)->finalize (object);
}
@@ -1467,13 +1468,17 @@ g_subprocess_communicate_state_free (gpointer data)
{
CommunicateState *state = data;
+ g_clear_object (&state->cancellable);
g_clear_object (&state->stdin_buf);
g_clear_object (&state->stdout_buf);
g_clear_object (&state->stderr_buf);
- if (!g_source_is_destroyed (state->cancellable_source))
- g_source_destroy (state->cancellable_source);
- g_source_unref (state->cancellable_source);
+ if (state->cancellable_source)
+ {
+ if (!g_source_is_destroyed (state->cancellable_source))
+ g_source_destroy (state->cancellable_source);
+ g_source_unref (state->cancellable_source);
+ }
g_slice_free (CommunicateState, state);
}
@@ -1539,6 +1544,7 @@ g_subprocess_communicate_internal (GSubprocess *subprocess,
g_subprocess_communicate_made_progress, g_object_ref (task));
state->outstanding_ops++;
+ g_object_unref (task);
return state;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]