tgsi: Fix memory leak in out-of-memory path.
authorVinson Lee <vlee@vmware.com>
Tue, 25 Oct 2011 15:23:02 +0000 (08:23 -0700)
committerVinson Lee <vlee@vmware.com>
Tue, 25 Oct 2011 18:12:51 +0000 (11:12 -0700)
Fixes Coverity resource leak defect.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_exec.c

index b4eea54..1fb7f8f 100644 (file)
@@ -674,16 +674,19 @@ tgsi_exec_machine_bind_shader(
 
    if (mach->Processor == TGSI_PROCESSOR_GEOMETRY &&
        !mach->UsedGeometryShader) {
-      struct tgsi_exec_vector *inputs =
-         align_malloc(sizeof(struct tgsi_exec_vector) *
-                      TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS,
-                      16);
-      struct tgsi_exec_vector *outputs =
-         align_malloc(sizeof(struct tgsi_exec_vector) *
-                      TGSI_MAX_TOTAL_VERTICES, 16);
+      struct tgsi_exec_vector *inputs;
+      struct tgsi_exec_vector *outputs;
+
+      inputs = align_malloc(sizeof(struct tgsi_exec_vector) *
+                            TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS,
+                            16);
 
       if (!inputs)
          return;
+
+      outputs = align_malloc(sizeof(struct tgsi_exec_vector) *
+                             TGSI_MAX_TOTAL_VERTICES, 16);
+
       if (!outputs) {
          align_free(inputs);
          return;