[Spice-devel] [PATCH spice-gtk 2/2] webdav: ref client when demuxing

Frediano Ziglio fziglio at redhat.com
Thu Aug 22 07:01:42 UTC 2019


> 
> The client can be unrefed before the demux_to_client_cb() is called
> which could lead to segfault. So ref it first before starting the
> async write.
> 
> Signed-off-by: Jakub Janků <jjanku at redhat.com>

Acked-by: Frediano Ziglio <fziglio at redhat.com>

> ---
>  src/channel-webdav.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/channel-webdav.c b/src/channel-webdav.c
> index 09ef9f7..fb25084 100644
> --- a/src/channel-webdav.c
> +++ b/src/channel-webdav.c
> @@ -329,6 +329,7 @@ static void demux_to_client_cb(GObject *source,
> GAsyncResult *result, gpointer u
>      fail = (size != c->demux.size);
>      g_warn_if_fail(size == c->demux.size);
>      demux_to_client_finish(client, fail);
> +    client_unref(client);
>  }
>  #endif
>  
> @@ -348,7 +349,7 @@ static void demux_to_client(Client *client)
>  
>      g_output_stream_write_all_async(g_io_stream_get_output_stream(client->pipe),
>                                      c->demux.buf, size, G_PRIORITY_DEFAULT,
> -                                    c->cancellable, demux_to_client_cb,
> client);
> +                                    c->cancellable, demux_to_client_cb,
> client_ref(client));
>  #endif
>  }
>  


More information about the Spice-devel mailing list