[Mesa-dev] [PATCH 2/3] mesa: Use static buffer for uniform name

Ian Romanick idr at freedesktop.org
Wed Nov 16 11:08:22 PST 2011


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Eric Anholt <eric at anholt.net>
---
 src/mesa/main/ff_fragment_shader.cpp |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 1806adc..4808855 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1499,7 +1499,12 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    _mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters);
 
    for (unsigned int i = 0; i < MAX_TEXTURE_UNITS; i++) {
-      char *name = ralloc_asprintf(p.mem_ctx, "sampler_%d", i);
+      /* Enough space for 'sampler_999\0'.
+       */
+      char name[12];
+
+      snprintf(name, sizeof(name), "sampler_%d", i);
+
       int loc = _mesa_get_uniform_location(ctx, p.shader_program, name);
       if (loc != -1) {
 	 unsigned base;
-- 
1.7.6.4



More information about the mesa-dev mailing list