changeset 255:67acad9db5b3

Fix crash when no operand is present In cases where an instruction expects a general operand and nothing is provided, throw a bad operand error immediately instead of waiting to crash out with a segmentation fault.
author William Astle <lost@l-w.ca>
date Wed, 30 Jan 2013 21:40:34 -0700
parents 155799f6cfa5
children bc25269d96bc
files lwasm/insn_gen.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/insn_gen.c	Wed Jan 30 21:32:14 2013 -0700
+++ b/lwasm/insn_gen.c	Wed Jan 30 21:40:34 2013 -0700
@@ -41,6 +41,12 @@
 	int v1, tv;
 	lw_expr_t s;
 
+	if (!**p)
+	{
+		lwasm_register_error(as, l, "Bad operand");
+		return;
+	}
+
 	optr2 = *p;
 	while (*optr2 && !isspace(*optr2) && *optr2 != ',') optr2++
 		/* do nothing */ ;