Module: Mesa
Branch: master
Commit: ac2bddb9f2c40effb16db321db0177decea81a92
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac2bddb9f2c40effb16db321db0177decea81a92

Author: Tilman Sauerbeck <[email protected]>
Date:   Thu Sep  9 14:03:46 2010 +0200

r600g: Fixed a bo leak in r600_texture_from_handle().

We would leak bo if the argument check failed.

Signed-off-by: Tilman Sauerbeck <[email protected]>

---

 src/gallium/drivers/r600/r600_texture.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index dec616b..37907ef 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -199,11 +199,6 @@ struct pipe_resource *r600_texture_from_handle(struct 
pipe_screen *screen,
        struct r600_resource *resource;
        struct radeon_bo *bo = NULL;
 
-       bo = radeon_bo(rw, whandle->handle, 0, 0, NULL);
-       if (bo == NULL) {
-               return NULL;
-       }
-
        /* Support only 2D textures without mipmaps */
        if ((templ->target != PIPE_TEXTURE_2D && templ->target != 
PIPE_TEXTURE_RECT) ||
              templ->depth0 != 1 || templ->last_level != 0)
@@ -213,6 +208,12 @@ struct pipe_resource *r600_texture_from_handle(struct 
pipe_screen *screen,
        if (rtex == NULL)
                return NULL;
 
+       bo = radeon_bo(rw, whandle->handle, 0, 0, NULL);
+       if (bo == NULL) {
+               FREE(rtex);
+               return NULL;
+       }
+
        resource = &rtex->resource;
        resource->base.b = *templ;
        resource->base.vtbl = &r600_texture_vtbl;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to