Mesa (master): r300g: fix memory leaks in texture_create error paths
Marek Olšák
mareko at kemper.freedesktop.org
Sat Dec 1 21:48:59 UTC 2012
Module: Mesa
Branch: master
Commit: e694ea09f57cdce557a7424401e68b37e0e80fa7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e694ea09f57cdce557a7424401e68b37e0e80fa7
Author: Marek Olšák <maraeo at gmail.com>
Date: Sat Dec 1 22:38:36 2012 +0100
r300g: fix memory leaks in texture_create error paths
---
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 7f74538..33333ca 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. */
More information about the mesa-commit
mailing list