progs/util: Fix memory leak if fail to load/compile shader
authorVinson Lee <vlee@vmware.com>
Tue, 3 Nov 2009 21:41:08 +0000 (14:41 -0700)
committerVinson Lee <vlee@vmware.com>
Sat, 5 Dec 2009 01:32:48 +0000 (17:32 -0800)
Signed-off-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit c475079ef2d901ba4506ebd53e19419cd46793ab)

progs/util/shaderutil.c

index 629b6f1d972d74e6d206e37abc45f3cc3845a439..36e07842c6d0f98e78f2e2c1c8e764b16fa45229 100644 (file)
@@ -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;
    }