[Spice-devel] [spice-gtk 4/5] usb-redir: delete usb-backend context on initialization error

Yuri Benditovich yuri.benditovich at daynix.com
Tue Jul 16 20:18:44 UTC 2019


On Mon, Jul 15, 2019 at 5:28 PM Frediano Ziglio <fziglio at redhat.com> wrote:
>
> >
> > On Mon, Jul 15, 2019 at 5:04 PM Frediano Ziglio <fziglio at redhat.com> wrote:
> > >
> > > >
> > > > The delete in error flow was missing.
> > > >
> > > > Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com>
> > > > ---
> > > >  src/usb-device-manager.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> > > > index 857d057..7105ff1 100644
> > > > --- a/src/usb-device-manager.c
> > > > +++ b/src/usb-device-manager.c
> > > > @@ -259,6 +259,7 @@ static gboolean
> > > > spice_usb_device_manager_initable_init(GInitable  *initable,
> > > >      if (!spice_usb_backend_register_hotplug(priv->context, self,
> > > >                                              spice_usb_device_manager_hotplug_cb,
> > > >                                              err)) {
> > > > +        spice_usb_backend_delete(priv->context);
> > >
> > > Should not have a following "priv->context = NULL" ?
> >
> > This is a constructor; if it fails the destructor is not called.
> > But no problem to add this for beauty.
> >
>
> No, this is the Initiable::init. If this returns FALSE the object destruction
> (so spice_usb_device_manager_finalize for instance) will be executed.
> Currently spice_usb_device_manager_finalize is calling spice_usb_backend_delete
> also so in theory this call should not be necessary (not tested).

Tested. You're right, the patch is wrong. Without it in case of error
the remote-viewer start without USB redirection.

>
> > >
> > > >          return FALSE;
> > > >      }
> > > >  #ifndef G_OS_WIN32
> > >
>
> Frediano


More information about the Spice-devel mailing list