Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,13 @@ void freeUnitSymbolTable(Symbol *symbol_table) {
void toLowerString(char *str) {
if (!str) return;
for (int i = 0; str[i]; i++) {
str[i] = tolower(str[i]);
/*
* tolower expects either EOF or an unsigned char value. Passing a
* plain `char` that happens to be negative results in undefined
* behaviour on platforms where `char` is signed. Cast to
* unsigned char before calling tolower to ensure well-defined
* behaviour for characters with the high bit set.
*/
str[i] = (char)tolower((unsigned char)str[i]);
}
}