summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-10-01 14:55:13 -0600
committerBrian Paul <[email protected]>2009-10-01 14:55:13 -0600
commit167ffa9e035befd12143db909af424e5de8f64e4 (patch)
treecd960fd588d28010601e2f50f7b799576bc303e6
parent05749542384abc4d4776bfe2a386b6396002e0df (diff)
mesa: fix memory leak when generating mipmaps for compressed textures
-rw-r--r--src/mesa/main/mipmap.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 3dca09d9f28..4d3e62572d5 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1510,7 +1510,9 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
/* Find convertFormat - the format that do_row() will process */
if (srcImage->IsCompressed) {
- /* setup for compressed textures */
+ /* setup for compressed textures - need to allocate temporary
+ * image buffers to hold uncompressed images.
+ */
GLuint row;
GLint components, size;
GLchan *dst;
@@ -1587,11 +1589,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
&dstWidth, &dstHeight, &dstDepth);
if (!nextLevel) {
/* all done */
- if (srcImage->IsCompressed) {
- _mesa_free((void *) srcData);
- _mesa_free(dstData);
- }
- return;
+ break;
}
/* get dest gl_texture_image */
@@ -1682,6 +1680,12 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
}
} /* loop over mipmap levels */
+
+ if (srcImage->IsCompressed) {
+ /* free uncompressed image buffers */
+ _mesa_free((void *) srcData);
+ _mesa_free(dstData);
+ }
}