diff options
author | Marek Olšák <[email protected]> | 2012-12-01 22:38:36 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-12-01 22:38:36 +0100 |
commit | e694ea09f57cdce557a7424401e68b37e0e80fa7 (patch) | |
tree | 4e2d3acab2b44af71e007858d4600b9f89be1eac /src | |
parent | 3e3a586236815970b5eab36697e221e9a72542d6 (diff) |
r300g: fix memory leaks in texture_create error paths
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/r300/r300_texture.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7f74538deea..33333ca51b5 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -953,15 +953,16 @@ r300_texture_create_object(struct r300_screen *rscreen, struct pb_buffer *buffer) { struct radeon_winsys *rws = rscreen->rws; - struct r300_resource *tex = CALLOC_STRUCT(r300_resource); - if (!tex) { - if (buffer) - pb_reference(&buffer, NULL); - return NULL; + struct r300_resource *tex = NULL; + + if (base->nr_samples > 1) { + goto fail; } - if (base->nr_samples > 1) - return NULL; + tex = CALLOC_STRUCT(r300_resource); + if (!tex) { + goto fail; + } pipe_reference_init(&tex->b.b.reference, 1); tex->b.b.screen = &rscreen->screen; @@ -985,8 +986,7 @@ r300_texture_create_object(struct r300_screen *rscreen, base->bind, tex->domain); if (!tex->buf) { - FREE(tex); - return NULL; + goto fail; } } @@ -998,6 +998,12 @@ r300_texture_create_object(struct r300_screen *rscreen, tex->tex.stride_in_bytes[0]); return tex; + +fail: + FREE(tex); + if (buffer) + pb_reference(&buffer, NULL); + return NULL; } /* Create a new texture. */ |