[vlc-devel] [PATCH] picture_pool: fix refcount leak if pic_lock fails.

Rémi Denis-Courmont remi at remlab.net
Fri Oct 31 17:28:17 CET 2014


Le vendredi 31 octobre 2014, 17:24:59 Thomas Guillem a écrit :
> On Fri, Oct 31, 2014, at 17:11, Rémi Denis-Courmont wrote:
> > Le vendredi 31 octobre 2014, 16:30:51 Thomas Guillem a écrit :
> > > ---
> > > 
> > >  src/misc/picture_pool.c | 5 ++++-
> > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/src/misc/picture_pool.c b/src/misc/picture_pool.c
> > > index 2a0f677..771df99 100644
> > > --- a/src/misc/picture_pool.c
> > > +++ b/src/misc/picture_pool.c
> > > @@ -277,8 +277,11 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
> > > 
> > >          if (!atomic_compare_exchange_strong(&picture->gc.refcount,
> > >          &refs,
> > > 
> > > 1)) continue;
> > > 
> > > -        if (pool->pic_lock != NULL && pool->pic_lock(picture) != 0)
> > > +        if (pool->pic_lock != NULL && pool->pic_lock(picture) != 0) {
> > > +            refs = 1;
> > > +            atomic_compare_exchange_strong(&picture->gc.refcount,
> > > &refs,
> > > 0);
> > 
> > This does not make much sense to me.
> > What happens if the function returns false?
> 
> Ah yes I see. Is is better to force the refcount to 0 in that case ?
> With atomic_store, right ?

If you´re sure the value is still 1, yes.

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list