BUG: Do not use 'char' type as array subscript
This converts uses of 'char' as an array subscript to 'unsigned char' to heed the warning from gcc. The subscript must be an unsigned type to avoid indexing before the beginning of the array. This change avoids a potential crash if input text contains a byte value beyond 0x7f.
This commit is contained in:
parent
57a1d0093e
commit
ab629e28f3
|
@ -242,8 +242,8 @@ static char charmap[] = {
|
|||
inline int strcasecmpCM(const char *s1, const char *s2)
|
||||
{
|
||||
const char *cm = charmap;
|
||||
const char* us1 = s1;
|
||||
const char* us2 = s2;
|
||||
unsigned char const* us1 = reinterpret_cast<unsigned char const*>(s1);
|
||||
unsigned char const* us2 = reinterpret_cast<unsigned char const*>(s2);
|
||||
|
||||
while(cm[*us1] == cm[*us2++])
|
||||
if(*us1++ == '\0')
|
||||
|
|
|
@ -101,8 +101,8 @@ static char charmap[] = {
|
|||
inline int strcasecmpCM(const char *s1, const char *s2)
|
||||
{
|
||||
const char *cm = charmap;
|
||||
const char* us1 = s1;
|
||||
const char* us2 = s2;
|
||||
unsigned char const* us1 = reinterpret_cast<unsigned char const*>(s1);
|
||||
unsigned char const* us2 = reinterpret_cast<unsigned char const*>(s2);
|
||||
|
||||
while(cm[*us1] == cm[*us2++])
|
||||
if(*us1++ == '\0')
|
||||
|
|
Loading…
Reference in New Issue