mesa: Fix memory leak if we run out of memory
authorVinson Lee <vlee@vmware.com>
Wed, 28 Oct 2009 23:59:49 +0000 (17:59 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 28 Oct 2009 23:59:49 +0000 (17:59 -0600)
Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/main/texstore.c

index a22db628d3ed6c53e50c4f8b821b7a5184397409..d3237959e0ce3f64764721d6db849a83fa48bbc9 100644 (file)
@@ -589,8 +589,12 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
    /* unpack and transfer the source image */
    tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth
                                        * components * sizeof(GLchan));
-   if (!tempImage)
+   if (!tempImage) {
+      if (freeSrcImage) {
+         _mesa_free((void *) srcAddr);
+      }
       return NULL;
+   }
 
    dst = tempImage;
    for (img = 0; img < srcDepth; img++) {