ARB prog parser: Release old program string in _mesa_parse_arb_{fragment,vertex}_program
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 5 Nov 2009 22:17:07 +0000 (14:17 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 6 Nov 2009 18:46:22 +0000 (10:46 -0800)
The program structure passed to _mesa_parse_arb_program is just a
place holder.  The stings that actually need to be released are only
known to the functions calling _mesa_parse_arb_program, so they should
be freed there.

src/mesa/shader/arbprogparse.c
src/mesa/shader/program_parse.y

index 05ee4f563eb7a2fe8b40bb8c1ab76e03a882da98..dd732b6666bc07afa011c52929d68fca17f15b6a 100644 (file)
@@ -87,6 +87,9 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
       return;
    }
 
+   if (program->Base.String != NULL)
+      _mesa_free(program->Base.String);
+
    /* Copy the relevant contents of the arb_program struct into the
     * fragment_program struct.
     */
@@ -178,6 +181,9 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target,
       return;
    }
 
+   if (program->Base.String != NULL)
+      _mesa_free(program->Base.String);
+
    /* Copy the relevant contents of the arb_program struct into the 
     * vertex_program struct.
     */
index b2db2958be81fcbde52347e41482eef02fdb3db7..aad5eeb7da36e11501e59a22c5f8205557a87a82 100644 (file)
@@ -2304,10 +2304,6 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str,
    _mesa_memcpy (strz, str, len);
    strz[len] = '\0';
 
-   if (state->prog->String != NULL) {
-      _mesa_free(state->prog->String);
-   }
-
    state->prog->String = strz;
 
    state->st = _mesa_symbol_table_ctor();