Skip to content

Commit

Permalink
Update highscore.c
Browse files Browse the repository at this point in the history
Prevents the crash of the program if the user name contains UTF-8 characters.
  • Loading branch information
JoergStrebel committed Aug 19, 2021
1 parent 33c2c86 commit 0c61784
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/highscore.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ char *getUsersFullName()
/* shorten to 20 chars */
fullname[19] = 0;

/* SFont and TFont can only handle characters with values from 32d und 127d (ASCII) */
for (int i=0; i<=18; i++) {
if (fullname[i]>126 || fullname[i]<32) {
fullname[i]=32;
}
}

/* Return their name without any trailing stuff */
return(fullname);
}
Expand Down

0 comments on commit 0c61784

Please sign in to comment.