glsl: Use reralloc instead of plain realloc.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 27 Feb 2011 09:17:29 +0000 (01:17 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 28 Feb 2011 18:35:40 +0000 (10:35 -0800)
Plugs a memory leak when compiling shaders with user defined structures.

NOTE: This is a candidate for the 7.9 and 7.10 branches.

src/glsl/ast_to_hir.cpp

index bef099cca3b9036f76348e179f2584ee4e4bf015..fd1f0b49f42de2a3ca25de611f6fb60c910ae192 100644 (file)
@@ -3445,11 +3445,9 @@ ast_struct_specifier::hir(exec_list *instructions,
    if (!state->symbols->add_type(name, t)) {
       _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name);
    } else {
-
-      const glsl_type **s = (const glsl_type **)
-        realloc(state->user_structures,
-                sizeof(state->user_structures[0]) *
-                (state->num_user_structures + 1));
+      const glsl_type **s = reralloc(state, state->user_structures,
+                                    const glsl_type *,
+                                    state->num_user_structures + 1);
       if (s != NULL) {
         s[state->num_user_structures] = t;
         state->user_structures = s;