st/xvmc: exit gracefully if we fail to create video buffer
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 17 Aug 2013 20:45:19 +0000 (21:45 +0100)
committerChristian König <christian.koenig@amd.com>
Mon, 19 Aug 2013 16:32:07 +0000 (18:32 +0200)
Free any allocated memory and return BadAlloc if create_video_buffer()
has failed to create a buffer.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/gallium/state_trackers/xvmc/surface.c

index 2e67612f690ec4a620cfaf89920102fab82d34b3..13f337c61cd121a3383ff2685892c2680908655f 100644 (file)
@@ -193,6 +193,10 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
    );
 
    surface_priv->video_buffer = pipe->create_video_buffer(pipe, &tmpl);
+   if (!surface_priv->video_buffer) {
+      FREE(surface_priv);
+      return BadAlloc;
+   }
    surface_priv->context = context;
 
    surface->surface_id = XAllocID(dpy);