pp: Reorder calloc to avoid memory leak on error path.
authorVinson Lee <vlee@vmware.com>
Fri, 4 Nov 2011 03:55:10 +0000 (20:55 -0700)
committerVinson Lee <vlee@vmware.com>
Sun, 6 Nov 2011 05:06:35 +0000 (22:06 -0700)
Fixes Coverity resource leak defect.

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

index f514e692985702dc7b04be18b13d67067afa9bb9..51bc02edacce1f19cfbe47ed34bd3a0e1f0bfaa6 100644 (file)
@@ -212,9 +212,7 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
 
    struct pipe_box box;
    struct pipe_resource res;
-
-   char *tmp_text = CALLOC(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
-                           IMM_SPACE, sizeof(char));
+   char *tmp_text;
 
    constbuf = pipe_buffer_create(ppq->p->screen, PIPE_BIND_CONSTANT_BUFFER,
                                  PIPE_USAGE_STATIC, sizeof(constants));
@@ -226,6 +224,9 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
 
    pp_debug("mlaa: using %u max search steps\n", val);
 
+   tmp_text = CALLOC(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
+                     IMM_SPACE, sizeof(char));
+
    if (!tmp_text) {
       pp_debug("Failed to allocate shader space\n");
       return;