Mesa (mesa_7_6_branch): progs/util: Fix memory leak if fail to load/ compile shader

Vinson Lee vlee at kemper.freedesktop.org
Fri Dec 4 17:34:36 PST 2009


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

Author: Vinson Lee <vlee at vmware.com>
Date:   Tue Nov  3 14:41:08 2009 -0700

progs/util: Fix memory leak if fail to load/compile shader

Signed-off-by: Brian Paul <brianp at vmware.com>
(cherry picked from commit c475079ef2d901ba4506ebd53e19419cd46793ab)

---

 progs/util/shaderutil.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c
index 629b6f1..36e0784 100644
--- a/progs/util/shaderutil.c
+++ b/progs/util/shaderutil.c
@@ -88,6 +88,7 @@ CompileShaderFile(GLenum shaderType, const char *filename)
    f = fopen(filename, "r");
    if (!f) {
       fprintf(stderr, "Unable to open shader file %s\n", filename);
+      free(buffer);
       return 0;
    }
 
@@ -98,6 +99,7 @@ CompileShaderFile(GLenum shaderType, const char *filename)
       shader = CompileShaderText(shaderType, buffer);
    }
    else {
+      free(buffer);
       return 0;
    }
 



More information about the mesa-commit mailing list