[Spice-devel] [spice-gtk v1 06/10] file-transfer: Fix SpiceFileTransferTask::error leak

Victor Toso lists at victortoso.com
Mon Aug 1 15:42:12 UTC 2016


Hi,

On Mon, Aug 01, 2016 at 05:31:39PM +0200, Christophe Fergeau wrote:
> > > I think you'll need at least something like
> > > diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
> > > index 70571f0..ba99e1f 100644
> > > --- a/src/spice-file-transfer-task.c
> > > +++ b/src/spice-file-transfer-task.c
> > > @@ -122,6 +122,7 @@ static void spice_file_transfer_task_query_info_cb(GObject *obj,
> > >          g_clear_error(&error);
> > >          /* Return error previously reported */
> > >          g_task_return_error(task, self->error);
> > > +        self->error = NULL;
> > 
> > Not really.
> > 
> 
> Ah, I was not suggesting changing the overall design, but
> g_task_return_error() takes ownership of self->error
> « Note that since the task takes ownership of error , and since the task
> may be completed before returning from g_task_return_error(), you cannot
> assume that error is still valid after calling this. Call g_error_copy()
> on the error if you need to keep a local copy ».
> I would not call g_clear_error(&self->error); after calling
> g_task_return_error() as it's now owned by the GTask, and then by the
> caller of g_task_propagate_*
> 
> Christophe

Right! I totally missed it! g_error_copy() then :)
  toso


More information about the Spice-devel mailing list