st/mesa: fix memory leak in st_translate_mesa_program
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Sun, 17 Jan 2010 22:47:53 +0000 (14:47 -0800)
committerBrian Paul <brianp@vmware.com>
Mon, 18 Jan 2010 17:39:27 +0000 (10:39 -0700)
Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_mesa_to_tgsi.c

index e788008dfe1d337c3e0bfbb7e02a21afde99c3c2..f07846f8212224e3d5216fa9d178b9168e90375a 100644 (file)
@@ -779,6 +779,7 @@ st_translate_mesa_program(
 {
    struct st_translate translate, *t;
    unsigned i;
+   enum pipe_error ret = PIPE_OK;
 
    t = &translate;
    memset(t, 0, sizeof *t);
@@ -865,8 +866,10 @@ st_translate_mesa_program(
       
       t->constants = CALLOC( program->Parameters->NumParameters,
                              sizeof t->constants[0] );
-      if (t->constants == NULL)
+      if (t->constants == NULL) {
+         ret = PIPE_ERROR_OUT_OF_MEMORY;
          goto out;
+      }
       
       for (i = 0; i < program->Parameters->NumParameters; i++) {
          switch (program->Parameters->Parameters[i].Type) {
@@ -920,8 +923,6 @@ st_translate_mesa_program(
                         t->insn[t->labels[i].branch_target] );
    }
 
-   return PIPE_OK;
-
 out:
    FREE(t->insn);
    FREE(t->labels);
@@ -931,7 +932,7 @@ out:
       debug_printf("%s: translate error flag set\n", __FUNCTION__);
    }
 
-   return PIPE_ERROR_OUT_OF_MEMORY;
+   return ret;
 }