st/vdpau: Fix memory leak in vlVdpOutputSurfaceCreate.
[mesa.git] / src / gallium / state_trackers / vdpau / output.c
index 5b25e63d28e48703dd382563619b638be6922862..8237eaceb266f46c46d24cd80903c8cdf4e8c07f 100644 (file)
@@ -86,6 +86,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
    if (!res) {
       pipe_mutex_unlock(dev->mutex);
       FREE(dev);
+      FREE(vlsurface);
       return VDP_STATUS_ERROR;
    }
 
@@ -100,7 +101,6 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
 
    memset(&surf_templ, 0, sizeof(surf_templ));
    surf_templ.format = res->format;
-   surf_templ.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
    vlsurface->surface = pipe->create_surface(pipe, res, &surf_templ);
    if (!vlsurface->surface) {
       pipe_resource_reference(&res, NULL);
@@ -207,15 +207,8 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
 
    res = vlsurface->sampler_view->texture;
    box = RectToPipeBox(source_rect, res);
-   transfer = pipe->get_transfer(pipe, res, 0, PIPE_TRANSFER_READ, &box);
-   if (transfer == NULL) {
-      pipe_mutex_unlock(vlsurface->device->mutex);
-      return VDP_STATUS_RESOURCES;
-   }
-
-   map = pipe_transfer_map(pipe, transfer);
-   if (map == NULL) {
-      pipe_transfer_destroy(pipe, transfer);
+   map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer);
+   if (!map) {
       pipe_mutex_unlock(vlsurface->device->mutex);
       return VDP_STATUS_RESOURCES;
    }
@@ -224,7 +217,6 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface,
                   box.width, box.height, map, transfer->stride, 0, 0);
 
    pipe_transfer_unmap(pipe, transfer);
-   pipe_transfer_destroy(pipe, transfer);
    pipe_mutex_unlock(vlsurface->device->mutex);
 
    return VDP_STATUS_OK;