diff lwasm/lwasm.c @ 13:c80e5a063967

Brought forward patch to fix segfault with output outside of a section
author lost@l-w.ca
date Sat, 22 Jan 2011 16:15:32 -0700
parents 7317fbe024af
children 421d7ceb4d86
line wrap: on
line diff
--- a/lwasm/lwasm.c	Sat Jan 22 16:11:15 2011 -0700
+++ b/lwasm/lwasm.c	Sat Jan 22 16:15:32 2011 -0700
@@ -227,6 +227,11 @@
 
 void lwasm_emit(line_t *cl, int byte)
 {
+	if (cl -> as -> output_format == OUTPUT_OBJ && cl -> csect == NULL)
+	{
+		lwasm_register_error(cl -> as, cl, "Instruction generating output outside of a section");
+		return;
+	}
 	if (cl -> outputl < 0)
 		cl -> outputl = 0;
 
@@ -662,6 +667,12 @@
 		{
 			reloctab_t *re;
 			lw_expr_t te;
+
+			if (l -> csect == NULL)
+			{
+				lwasm_register_error(l -> as, l, "Instruction generating output outside of a section");
+				return;
+			}
 			
 			if (size == 4)
 			{