comparison 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
comparison
equal deleted inserted replaced
254:155799f6cfa5 255:67acad9db5b3
38 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p, int elen) 38 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p, int elen)
39 { 39 {
40 const char *optr2; 40 const char *optr2;
41 int v1, tv; 41 int v1, tv;
42 lw_expr_t s; 42 lw_expr_t s;
43
44 if (!**p)
45 {
46 lwasm_register_error(as, l, "Bad operand");
47 return;
48 }
43 49
44 optr2 = *p; 50 optr2 = *p;
45 while (*optr2 && !isspace(*optr2) && *optr2 != ',') optr2++ 51 while (*optr2 && !isspace(*optr2) && *optr2 != ',') optr2++
46 /* do nothing */ ; 52 /* do nothing */ ;
47 53