- Create a dummy program to keep from segfaulting when parsing
fails
- Change to grammar .emit to fix single LOCAL/ENV param usage
diff --git a/src/mesa/main/arbfragparse.c b/src/mesa/main/arbfragparse.c
index ca4b68d..a12fd93 100644
--- a/src/mesa/main/arbfragparse.c
+++ b/src/mesa/main/arbfragparse.c
@@ -189,24 +189,6 @@
retval = _mesa_parse_arb_program(ctx, str, len, &ap);
- /* XXX: Parse error. Cleanup things and return */
- if (retval)
- {
- return;
- }
-
- /* XXX: Eh.. we parsed something that wasn't a fragment program. doh! */
- if (ap.type != GL_FRAGMENT_PROGRAM_ARB)
- {
- return;
- }
-
-#if DEBUG_FP
- debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
-#else
- (void) debug_fp_inst;
-#endif
-
/* copy the relvant contents of the arb_program struct into the
* fragment_program struct
*/
@@ -216,7 +198,6 @@
program->Base.NumAttributes = ap.Base.NumAttributes;
program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
- program->Instructions = ap.FPInstructions;
program->InputsRead = ap.InputsRead;
program->OutputsWritten = ap.OutputsWritten;
for (retval=0; retval<MAX_TEXTURE_IMAGE_UNITS; retval++)
@@ -225,4 +206,32 @@
program->NumTexInstructions = ap.NumTexInstructions;
program->NumTexIndirections = ap.NumTexIndirections;
program->Parameters = ap.Parameters;
+
+ /* XXX: Parse error. Cleanup things and return */
+ if (retval)
+ {
+ program->Instructions = (struct fp_instruction *) _mesa_malloc (
+ sizeof(struct fp_instruction) );
+ program->Instructions[0].Opcode = FP_OPCODE_END;
+ return;
+ }
+
+ /* XXX: Eh.. we parsed something that wasn't a fragment program. doh! */
+ if (ap.type != GL_FRAGMENT_PROGRAM_ARB)
+ {
+ program->Instructions = (struct fp_instruction *) _mesa_malloc (
+ sizeof(struct fp_instruction) );
+ program->Instructions[0].Opcode = FP_OPCODE_END;
+
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Parsed a non-fragment program as a fragment program");
+ return;
+ }
+
+#if DEBUG_FP
+ debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
+#else
+ (void) debug_fp_inst;
+#endif
+
+ program->Instructions = ap.FPInstructions;
}