fix overflow issue
(1 << (1 + 6 + 6 + 6 + 6 + 6)) is signed -2147483648 and unsigned 2147483648. We want to check against the unsigned value, and since g is signed we need to cast. CID 1100656, 1100660
This commit is contained in:
parent
cd189663bd
commit
12617004ee
|
@ -43,7 +43,7 @@ codepoint_to_utf8(int g, char *txt)
|
|||
txt[5] = 0;
|
||||
return 5;
|
||||
}
|
||||
else if (g < (1 << (1 + 6 + 6 + 6 + 6 + 6)))
|
||||
else if (g < (unsigned int)(1 << (1 + 6 + 6 + 6 + 6 + 6)))
|
||||
{ // 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
txt[0] = 0xfc | ((g >> 30) & 0x01);
|
||||
txt[1] = 0x80 | ((g >> 24) & 0x3f);
|
||||
|
|
Loading…
Reference in New Issue