summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorVictor van den Elzen <victor.vde@gmail.com>2009-06-23 03:47:07 +0200
committerVictor van den Elzen <victor.vde@gmail.com>2009-06-23 03:56:07 +0200
commit02846d30c0a77293ad481b4f98f6fa6b6b71cb74 (patch)
tree340a84fbd82566ef2aaf2cd67f57b332605c1f75 /parser.c
parent1957e65ca4ad6fd351d58149b08f5c55cae0d735 (diff)
downloadnasm-02846d30c0a77293ad481b4f98f6fa6b6b71cb74.tar.gz
nasm-02846d30c0a77293ad481b4f98f6fa6b6b71cb74.tar.bz2
nasm-02846d30c0a77293ad481b4f98f6fa6b6b71cb74.zip
BR 2782055: reject invalid tokens after ]
A bracketed memory reference should be followed by a comma or the end of the line. Enforce this.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/parser.c b/parser.c
index 0f64043..450511b 100644
--- a/parser.c
+++ b/parser.c
@@ -678,24 +678,32 @@ restart_parse:
return result; /* ignore this instruction */
}
}
+
+ bool recover = false;
if (mref && bracket) { /* find ] at the end */
if (i != ']') {
error(ERR_NONFATAL, "parser: expecting ]");
- do { /* error recovery again */
- i = stdscan(NULL, &tokval);
- } while (i != 0 && i != ',');
- } else /* we got the required ] */
+ recover = true;
+ } else { /* we got the required ] */
i = stdscan(NULL, &tokval);
+ if (i != 0 && i != ',') {
+ error(ERR_NONFATAL, "comma or end of line expected");
+ recover = true;
+ }
+ }
} else { /* immediate operand */
if (i != 0 && i != ',' && i != ':') {
- error(ERR_NONFATAL, "comma or end of line expected");
- do { /* error recovery */
- i = stdscan(NULL, &tokval);
- } while (i != 0 && i != ',');
+ error(ERR_NONFATAL, "comma, colon or end of line expected");
+ recover = true;
} else if (i == ':') {
result->oprs[operand].type |= COLON;
}
}
+ if (recover) {
+ do { /* error recovery */
+ i = stdscan(NULL, &tokval);
+ } while (i != 0 && i != ',');
+ }
/* now convert the exprs returned from evaluate() into operand
* descriptions... */