From 4073009d199cf6b05f7ce92b904c8ffc260eb6c7 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Tue, 24 Oct 2023 17:51:51 -0400 Subject: mapScore: Fix segmentation fault --- mapScore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mapScore.c') diff --git a/mapScore.c b/mapScore.c index 9c40795..1135c2b 100644 --- a/mapScore.c +++ b/mapScore.c @@ -20,7 +20,7 @@ void makeMap(FILE *f) { map[c][1] = y; map[c][2] = 1; c = toupper(c); - if (map[toupper(c)][2] == 0) goto explicit_label; + if (c < 256 && map[c][2] == 0) goto explicit_label; break; } } @@ -33,8 +33,8 @@ int scoreWord(char *word, int (*fun)(int*,int*)) { for (c++;*c;c++) { if (*c == '\n') break; // pass over ignore unset chars. - if(map[(unsigned)*c][3] == 0) continue; - score += (*fun)(map[(unsigned)*p],map[(unsigned)*c]); + if(map[(unsigned char)*c][3] == 0) continue; + score += (*fun)(map[(unsigned char)*p],map[(unsigned char)*c]); p=c; } return score; -- cgit 1.4.1