[Spice-devel] [spice-gtk] Check coroutine_init() return value

Christophe Fergeau cfergeau at redhat.com
Mon Nov 18 09:46:22 PST 2013


On Mon, Nov 18, 2013 at 06:00:16PM +0100, Christophe Fergeau wrote:
> 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()
> ---
>  gtk/coroutine.h          | 2 +-
>  gtk/coroutine_ucontext.c | 6 ++++++
>  gtk/spice-channel.c      | 9 ++++++++-
>  3 files changed, 15 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/coroutine_ucontext.c b/gtk/coroutine_ucontext.c
> index f4ff22e..f391f28 100644
> --- a/gtk/coroutine_ucontext.c
> +++ b/gtk/coroutine_ucontext.c
> @@ -65,6 +65,12 @@ static void coroutine_trampoline(struct continuation *cc)
>  
>  int coroutine_init(struct coroutine *co)
>  {
> +    static int init_count = 1;
> +    if (init_count % 10 == 0) {
> +        g_warning("failing corouitne_init!!");
> +        return -1;
> +    }
> +    init_count++;

This is just some debugging leftover, gone already.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20131118/1d2f94ad/attachment.pgp>


More information about the Spice-devel mailing list