aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-03-09 03:33:31 -0400
committerB. Watson <urchlay@slackware.uk>2025-03-09 03:33:31 -0400
commitcd18873bdf82b327dfc5f6a15da40ca9f31204c3 (patch)
tree6c41c4fabec69f17c49ce6114e0aa8716ca70c85
parentf83939324458821440c39c9f63ed3a4a087c750a (diff)
downloadbw-atari8-tools-cd18873bdf82b327dfc5f6a15da40ca9f31204c3.tar.gz
listamsb: fix invalid token detection in expand_token() (for the -D option).
-rw-r--r--listamsb.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/listamsb.c b/listamsb.c
index 9eff533..2581a61 100644
--- a/listamsb.c
+++ b/listamsb.c
@@ -569,10 +569,15 @@ void expand_token(int ext, unsigned char t, unsigned char *buf) {
return;
}
- if(ext)
+ if(ext) {
+ if(t > MAX_EXT_TOK)
+ die("invalid token in program, can't decrunch");
result = ext_tokens[t - MIN_EXT_TOK];
- else
+ } else {
+ if(t > MAX_STD_TOK)
+ die("invalid token in program, can't decrunch");
result = std_tokens[t - MIN_STD_TOK];
+ }
strcpy((char *)buf, result);
}
@@ -589,9 +594,6 @@ int need_space_between(int ext1, int ext2, unsigned char t1, unsigned char t2) {
if(!t2) return 0; /* end of line */
if(t1 < 0x80 && t2 < 0x80) return 0; /* 2 ASCII chars */
- if(t1 > MAX_STD_TOK || t2 > MAX_STD_TOK)
- die("invalid token in program, can't decrunch");
-
expand_token(ext1, t1, tok1);
expand_token(ext2, t2, tok2);
t1last = tok1[strlen((char *)tok1) - 1]; /* "PRINT" => "T" */