Re: [vdagent-linux] udscs: Fix memory ownership issues with udscs_read_callback

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

 



On Fri, Nov 25, 2016 at 05:54:56AM +0100, Francois Gouget wrote:
> 
> Thanks for this patch, I think it makes the code more consistent and 
> cleaner. While rechecking this I think I found a wrinkle though:
> 
> 
> On Wed, 9 Nov 2016, Christophe Fergeau wrote:
> [...]
> > diff --git a/src/udscs.c b/src/udscs.c
> > index 427a844..b468e71 100644
> > --- a/src/udscs.c
> > +++ b/src/udscs.c
> > @@ -132,6 +132,7 @@ void udscs_destroy_connection(struct udscs_connection **connp)
> >      }
> >  
> >      free(conn->data.buf);
> > +    conn->data.buf = NULL;
> >  
> >      if (conn->next)
> >          conn->next->prev = conn->prev;
> > @@ -235,6 +236,7 @@ static void udscs_read_complete(struct udscs_connection **connp)
> >          if (!*connp) /* Was the connection disconnected by the callback ? */
> >              return;
> >      }
> > +    free(conn->data.buf);
> >
> 
> Why is conn->data.buf not set to NULL here?
> 

The code is:

    if (conn->read_callback) {
        conn->read_callback(connp, &conn->header, conn->data.buf);
        if (!*connp) /* Was the connection disconnected by the callback ? */
            return;
    }
    free(conn->data.buf);

    conn->header_read = 0;
    memset(&conn->data, 0, sizeof(conn->data));


This memset should 'buf' to NULL. (can't remember if I took that into account
while writing the patch though :)

Christophe

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]