Mesa (master): pp: Reorder calloc to avoid memory leak on error path.

Vinson Lee vlee at kemper.freedesktop.org
Sun Nov 6 05:07:35 UTC 2011


Module: Mesa
Branch: master
Commit: 9288253051feb05ba155e4f939284360fdd70b15
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9288253051feb05ba155e4f939284360fdd70b15

Author: Vinson Lee <vlee at vmware.com>
Date:   Thu Nov  3 20:55:10 2011 -0700

pp: Reorder calloc to avoid memory leak on error path.

Fixes Coverity resource leak defect.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/auxiliary/postprocess/pp_mlaa.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c
index f514e69..51bc02e 100644
--- a/src/gallium/auxiliary/postprocess/pp_mlaa.c
+++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c
@@ -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;




More information about the mesa-commit mailing list