[PATCH xserver 1/9] xvmc: Fix unchecked AddResource

Julien Cristau jcristau at debian.org
Tue Mar 8 08:30:40 UTC 2016


On Tue, Mar  8, 2016 at 09:12:34 +0100, walter harms wrote:

> 
> 
> Am 07.03.2016 23:20, schrieb Julien Cristau:
> > Signed-off-by: Julien Cristau <jcristau at debian.org>
> > ---
> >  Xext/xvmc.c | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Xext/xvmc.c b/Xext/xvmc.c
> > index 64eda92..7565c17 100644
> > --- a/Xext/xvmc.c
> > +++ b/Xext/xvmc.c
> > @@ -253,6 +253,10 @@ ProcXvMCCreateContext(ClientPtr client)
> >          free(pContext);
> >          return result;
> >      }
> > +    if (!AddResource(pContext->context_id, XvMCRTContext, pContext)) {
> > +        free(data);
> > +        return BadAlloc;
> > +    }
> >  
> >      rep = (xvmcCreateContextReply) {
> >          .type = X_Reply,
> > @@ -266,7 +270,6 @@ ProcXvMCCreateContext(ClientPtr client)
> >      WriteToClient(client, sizeof(xvmcCreateContextReply), &rep);
> >      if (dwords)
> >          WriteToClient(client, dwords << 2, data);
> > -    AddResource(pContext->context_id, XvMCRTContext, pContext);
> >  
> >      free(data);
> >  
> > @@ -329,6 +332,11 @@ ProcXvMCCreateSurface(ClientPtr client)
> >          free(pSurface);
> >          return result;
> >      }
> > +    if (!AddResource(pSurface->surface_id, XvMCRTSurface, pSurface)) {
> > +        free(data);
> > +        return BadAlloc;
> > +    }
> > +
> 
> 
> I do not see the whole picture but the free a few lines before indicate that
> the error path may need to free other previously allocated resources.
> 
If AddResource fails it'll have freed pSurface already.

Cheers,
Julien


More information about the xorg-devel mailing list