On 12/14/2011 11:26 PM, Pekka Paalanen wrote:
string_to_uint_map::put() already does a strdup() for the key argument,
so we leak the memory allocated by strdup() in link_uniforms.cpp.

Remove the extra strdup(), fixes a few Valgrind detected leaks.

Have you run piglit on this? I seem to recall adding the extra strdup for a reason. The hash table keeps a copy of the key pointer passed to it, and the underlying object may be deleted before the hash table is deleted. This can happen if the back-end optimizes some uniforms away after the linker has generated the list of "active" uniforms. I'm pretty sure there were one or two test cases that hit this on i965.

Signed-off-by: Pekka Paalanen<ppaala...@gmail.com>
---
  src/glsl/link_uniforms.cpp |    3 +--
  1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index c7de480..f6094d7 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -174,8 +174,7 @@ private:
        if (this->map->get(id, name))
         return;

-      char *key = strdup(name);
-      this->map->put(this->num_active_uniforms, key);
+      this->map->put(this->num_active_uniforms, name);

        /* Each leaf uniform occupies one entry in the list of active
         * uniforms.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to