From: Taylor R Campbell Date: Sun, 16 Dec 2018 01:11:58 +0000 (+0000) Subject: Convert char to unsigned char before using islower/toupper. X-Git-Tag: mit-scheme-pucked-10.1.9~3^2~35^2~1 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a7cabf16c6c579586b3b490556857dfdcda89ae5;p=mit-scheme.git Convert char to unsigned char before using islower/toupper. Failure to do so is undefined behaviour for any negative char values. --- diff --git a/src/microcode/findprim.c b/src/microcode/findprim.c index f85f5e232..93eb3c162 100644 --- a/src/microcode/findprim.c +++ b/src/microcode/findprim.c @@ -1206,8 +1206,8 @@ strcmp_ci (const char * s1, const char * s2) while ((length--) > 0) { - int c1 = (*s1++); - int c2 = (*s2++); + int c1 = ((unsigned char) (*s1++)); + int c2 = ((unsigned char) (*s2++)); if (islower (c1)) c1 = (toupper (c1)); if (islower (c2)) c2 = (toupper (c2)); if (c1 < c2) return (-1);