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)
committerBrian Paul <brianp@vmware.com>
Tue, 3 Nov 2009 21:49:41 +0000 (14:49 -0700)
Signed-off-by: Brian Paul <brianp@vmware.com>
progs/util/shaderutil.c

index 4db950016b890149506250f2f66c3cb723733edb..af50d64f510ce86d2115abb3a737f160bc624209 100644 (file)
@@ -84,6 +84,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;
    }
 
@@ -94,6 +95,7 @@ CompileShaderFile(GLenum shaderType, const char *filename)
       shader = CompileShaderText(shaderType, buffer);
    }
    else {
+      free(buffer);
       return 0;
    }