Catch overflow

This commit is contained in:
Devine Lu Linvega 2024-04-07 20:59:45 -07:00
parent 9952b16163
commit d73bf177d5
1 changed files with 3 additions and 3 deletions

View File

@ -165,7 +165,7 @@ parse_rulefrag(char *line)
static int static int
rewrite(void) rewrite(void)
{ {
char c, *p = direction ? bank_b : bank_a; char c, *p = direction ? bank_b : bank_a, *o = p;
while((c = *p) && c <= ' ') p++; while((c = *p) && c <= ' ') p++;
while((c = *p)) { while((c = *p)) {
int i; int i;
@ -176,13 +176,13 @@ rewrite(void)
r->b = parse_rulefrag(p), p = walk(p); r->b = parse_rulefrag(p), p = walk(p);
return save(-1, p); return save(-1, p);
} }
if(p == bank_a || p == bank_b || spacer(*(p - 1))) { if(p == o || spacer(*(p - 1))) {
for(i = 0; i < rules_len; i++) { for(i = 0; i < rules_len; i++) {
Rule *r = &rules[i]; Rule *r = &rules[i];
char *res = match(p, r); char *res = match(p, r);
if(res != NULL) { if(res != NULL) {
char cc, *b = r->b; char cc, *b = r->b;
if(!*b) outp_--; if(!*b && outp_ != bank_a && outp_ != bank_b) outp_--;
while((cc = *b++)) { while((cc = *b++)) {
if(cc == '?' && regs[(int)b[0]]) if(cc == '?' && regs[(int)b[0]])
commit(*b++); commit(*b++);