Mercurial > hg > index.cgi
diff lwasm/insn_gen.c @ 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 | ea092ebc5323 |
children | 210d261a614d |
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 */ ;