# HG changeset patch # User William Astle # Date 1359607234 25200 # Node ID 67acad9db5b35a063da368d4a1dd2471108a84d1 # Parent 155799f6cfa5197bb254d72fa467830988da5260 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. diff -r 155799f6cfa5 -r 67acad9db5b3 lwasm/insn_gen.c --- 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 */ ;