fix mem leak (free key)
authorBrian <brian.paul@tungstengraphics.com>
Wed, 26 Dec 2007 13:56:42 +0000 (06:56 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 1 Jan 2008 17:21:21 +0000 (10:21 -0700)
src/mesa/main/ffvertex_prog.c

index 8fcb9e5b1404ad3b87f86a04d254b9444cd07c60..4a9a0cd975d4e9eb508b3fd26148a73d59ea08c4 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * 
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -1529,6 +1529,8 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
         
       prog = (struct gl_vertex_program *)
          ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); 
+      if (!prog)
+         return NULL;
 
       create_new_program( key, prog,
                           ctx->Const.VertexProgram.MaxTemps );
@@ -1541,10 +1543,8 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
       _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
                                  key, sizeof(*key), &prog->Base);
    }
-   else {
-      /* use cached program */
-      _mesa_free(key);
-   }
+
+   _mesa_free(key);
 
    return prog;
 }