Mesa (mesa_7_6_branch): mesa: Fix memory leak if we run out of memory

Brian Paul brianp at kemper.freedesktop.org
Wed Oct 28 23:59:51 UTC 2009


Module: Mesa
Branch: mesa_7_6_branch
Commit: 96128fdf2f959e2b59eca8f234dc6f3adf7a553f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=96128fdf2f959e2b59eca8f234dc6f3adf7a553f

Author: Vinson Lee <vlee at vmware.com>
Date:   Wed Oct 28 17:59:49 2009 -0600

mesa: Fix memory leak if we run out of memory

Signed-off-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/texstore.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index a22db62..d323795 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -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++) {




More information about the mesa-commit mailing list