glsl: Fix memory leak in builtin_builder::_image_prototype.
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 1 Oct 2014 10:12:38 +0000 (12:12 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Thu, 2 Oct 2014 13:39:05 +0000 (15:39 +0200)
in_var calls the ir_variable constructor, which dups the variable name.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/glsl/builtin_functions.cpp

index 5a024cb4386067726178ce84401810befc464deb..7d61fcc3561e367283f8f3ca01da79a548de6165 100644 (file)
@@ -4465,9 +4465,11 @@ builtin_builder::_image_prototype(const glsl_type *image_type,
       sig->parameters.push_tail(in_var(glsl_type::int_type, "sample"));
 
    /* Data arguments. */
-   for (unsigned i = 0; i < num_arguments; ++i)
-      sig->parameters.push_tail(in_var(data_type,
-                                       ralloc_asprintf(NULL, "arg%d", i)));
+   for (unsigned i = 0; i < num_arguments; ++i) {
+      char *arg_name = ralloc_asprintf(NULL, "arg%d", i);
+      sig->parameters.push_tail(in_var(data_type, arg_name));
+      ralloc_free(arg_name);
+   }
 
    /* Set the maximal set of qualifiers allowed for this image
     * built-in.  Function calls with arguments having fewer