diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-11-18 17:49:46 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-11-18 18:03:35 +0100 |
commit | 63272af5966d4866789ce4f2b6ae8842fee195b5 (patch) | |
tree | 5dae46731714829a5a97b275d4766ba0eaa671ae /gtk | |
parent | acb9b6863fe4527ca2b8ba197c1f97b07aca0c5f (diff) |
Check coroutine_init() return value
coroutine_init() can fail, but spice-channel.c was not checking its return
value, which could lead to some crashes if coroutine_init() failed and we
then try to use coroutine_yieldto()
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/coroutine.h | 2 | ||||
-rw-r--r-- | gtk/spice-channel.c | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/gtk/coroutine.h b/gtk/coroutine.h index 15b90b4..ef6f3db 100644 --- a/gtk/coroutine.h +++ b/gtk/coroutine.h @@ -56,7 +56,7 @@ struct coroutine }; #define IN_MAIN_CONTEXT (coroutine_self() == NULL || coroutine_is_main_context(coroutine_self())) -int coroutine_init(struct coroutine *co); +int coroutine_init(struct coroutine *co) G_GNUC_WARN_UNUSED_RESULT; int coroutine_release(struct coroutine *co); diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c index 41d5eab..d0b93f4 100644 --- a/gtk/spice-channel.c +++ b/gtk/spice-channel.c @@ -2358,6 +2358,7 @@ static gboolean connect_delayed(gpointer data) SpiceChannel *channel = data; SpiceChannelPrivate *c = channel->priv; struct coroutine *co; + int inited; CHANNEL_DEBUG(channel, "Open coroutine starting %p", channel); c->connect_delayed_id = 0; @@ -2368,7 +2369,13 @@ static gboolean connect_delayed(gpointer data) co->entry = spice_channel_coroutine; co->release = NULL; - coroutine_init(co); + inited = coroutine_init(co); + if (inited != 0) { + g_warning("Failed to initialize channel coroutine"); + CHANNEL_DEBUG(channel, "coroutine_init failed"); + g_object_unref(G_OBJECT(channel)); + return FALSE; + } coroutine_yieldto(co, channel); return FALSE; |