Fix UTF-8 character parsing due to improper casting (#401)

Upcasting of -ve signed characters (char) to signed integers (cell) results in -ve signed integers which don't represent valid printable characters.
eg. UTF-8 Character '中' (0xE4 0xB8 0xAD) when casted results in 0xFFFFFFE4 0xFFFFFFB8 0xFFFFFFAD which are not valid printable characters.
This commit is contained in:
souvikdas95 2017-01-17 20:20:00 +05:30 committed by Vincent Herbet
parent 9b3839de70
commit a30172f8a6

View File

@ -708,7 +708,7 @@ static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
c = *get_amxaddr(amx, params[iarg++]);
while (c-- && *arg)
*cptr++ = (cell)*arg++;
*cptr++ = (unsigned char)*arg++;
*cptr = 0;
}
}
@ -1006,7 +1006,7 @@ static cell AMX_NATIVE_CALL argparse(AMX *amx, cell *params)
break;
if (size_t(bufpos - buffer) < buflen)
*bufpos++ = input[i];
*bufpos++ = (unsigned char)input[i];
}
*bufpos = '\0';
@ -1068,7 +1068,7 @@ do_copy:
{
start = &(string[i]);
while (end--)
*right++ = (cell)*start++;
*right++ = (unsigned char)*start++;
}
*right = '\0';
return 1;