st/dri: Fix memory leak on error path.
authorVinson Lee <vlee@vmware.com>
Sun, 6 Nov 2011 05:19:31 +0000 (22:19 -0700)
committerVinson Lee <vlee@vmware.com>
Tue, 8 Nov 2011 04:36:07 +0000 (20:36 -0800)
Fixes Coverity resource leak defect.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/state_trackers/dri/drm/dri2.c

index a6bf3c1e10fbafe927fc0fba5bc66a01117274d5..4e3f1067ce24809b044c862fc00b381834ac1a83 100644 (file)
@@ -306,8 +306,10 @@ dri2_allocate_buffer(__DRIscreen *sPriv,
 
    buffer->resource =
       screen->base.screen->resource_create(screen->base.screen, &templ);
-   if (!buffer->resource)
+   if (!buffer->resource) {
+      FREE(buffer);
       return NULL;
+   }
 
    memset(&whandle, 0, sizeof(whandle));
    whandle.type = DRM_API_HANDLE_TYPE_SHARED;