diff options
author | Brian Paul <[email protected]> | 2005-10-29 15:52:31 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-10-29 15:52:31 +0000 |
commit | 4570364097eb27266eefaa4b2ffdd5dd22325805 (patch) | |
tree | 9443cbfcab28af62f78929beddcb9a22f290f8ee /src/mesa/shader/arbvertparse.c | |
parent | aba878d8c2d0d75b0762f7d8ae191fa438fc7d6a (diff) |
If parsing a program fails, don't change the vertex/fragment program object.
Specifically, don't attach a dummy program.
This change also fixes an occasional segfault.
Some code clean-ups. Use GLboolean instead of GLuint to return pass/fail.
Diffstat (limited to 'src/mesa/shader/arbvertparse.c')
-rw-r--r-- | src/mesa/shader/arbvertparse.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/mesa/shader/arbvertparse.c b/src/mesa/shader/arbvertparse.c index 92e3bb352e0..0208389c355 100644 --- a/src/mesa/shader/arbvertparse.c +++ b/src/mesa/shader/arbvertparse.c @@ -157,31 +157,29 @@ void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp) } +/** + * Parse the vertex program string. If success, update the given + * vertex_program object with the new program. Else, leave the vertex_program + * object unchanged. + */ void _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target, const GLubyte * str, GLsizei len, struct vertex_program *program) { - GLuint retval; struct arb_program ap; (void) target; /* set the program target before parsing */ ap.Base.Target = GL_VERTEX_PROGRAM_ARB; - retval = _mesa_parse_arb_program(ctx, str, len, &ap); - - /* Parse error. Allocate a dummy program and return */ - if (retval) - { - program->Instructions = (struct vp_instruction *) - _mesa_malloc ( sizeof(struct vp_instruction) ); - program->Instructions[0].Opcode = VP_OPCODE_END; + if (!_mesa_parse_arb_program(ctx, str, len, &ap)) { + /* Error in the program. Just return. */ return; } - /* copy the relvant contents of the arb_program struct into the - * fragment_program struct + /* Copy the relevant contents of the arb_program struct into the + * vertex_program struct. */ program->Base.String = ap.Base.String; program->Base.NumInstructions = ap.Base.NumInstructions; |