[Mesa-dev] [PATCH] mesa: Fix memory leak in _mesa_get_uniform_location.

Vinson Lee vlee at freedesktop.org
Fri Mar 23 00:09:48 PDT 2012


Fixes Coverity resource leak defect.

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 src/mesa/main/uniform_query.cpp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 991df78..da41ee8 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -905,8 +905,10 @@ _mesa_get_uniform_location(struct gl_context *ctx,
       name_copy[i-1] = '\0';
 
       offset = strtol(&name[i], NULL, 10);
-      if (offset < 0)
+      if (offset < 0) {
+	 free(name_copy);
 	 return -1;
+      }
 
       array_lookup = true;
    } else {
-- 
1.7.9.1



More information about the mesa-dev mailing list