Re: [spice-gtk] Check coroutine_init() return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: pgpPqmzOzAsMc.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]