Re: [PATCH spice-server 3/6] red-channel-client: Init pipe field during init

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

 



On Fri, Oct 28, 2016 at 11:59:53AM +0100, Frediano Ziglio wrote:
> There was a chance that on error GQueue were not
> initialized but an attempt to destroy it is made.
> This assure GQueue is initialized as soon as

s/assure/ensures

> possible. Note that red_channel_client_initable_init
> is called after all init and construction callbacks.

Did you hit an actual problem? Or did you notice this through
code-review?

What g_queue_init() is doing is setting all GQueue fields to 0, which
will be the case here anyway as the private data will be set to 0
initially, so trying to use priv->pipe before use should not cause harm.

I agree it's undefined behaviour though, so I'm fine with the patch if
this is something which was noticed during code reading. If you hit
crashes or issues related to that, I'd prefer that we have more details
about this in the log.

Christophe

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/red-channel-client.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/server/red-channel-client.c b/server/red-channel-client.c
> index c562e8e..3b2c24c 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -354,6 +354,8 @@ red_channel_client_init(RedChannelClient *self)
>      self->priv->send_data.urgent.marshaller = spice_marshaller_new();
>  
>      self->priv->send_data.marshaller = self->priv->send_data.main.marshaller;
> +
> +    g_queue_init(&self->priv->pipe);
>  }
>  
>  RedChannel* red_channel_client_get_channel(RedChannelClient *rcc)
> @@ -907,7 +909,6 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
>      self->priv->outgoing.pos = 0;
>      self->priv->outgoing.size = 0;
>  
> -    g_queue_init(&self->priv->pipe);
>      if (self->priv->stream)
>          self->priv->stream->watch =
>              core->watch_add(core, self->priv->stream->socket,
> -- 
> 2.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://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]