epp - fix bit underflow in bitshift for multibyte

this fixes CID 1193200
This commit is contained in:
Carsten Haitzler 2014-08-14 17:39:11 +09:00
parent 49694c9a64
commit e82b61b420
1 changed files with 3 additions and 2 deletions

View File

@ -412,9 +412,10 @@ cpp_lex(struct operation *op, cpp_reader * pfile)
{
int num_bits = num_chars * width;
if (cpp_lookup("__CHAR_UNSIGNED__",
if ((num_bits > 0) &&
(cpp_lookup("__CHAR_UNSIGNED__",
sizeof("__CHAR_UNSIGNED__") - 1, -1)
|| ((result >> (num_bits - 1)) & 1) == 0)
|| ((result >> (num_bits - 1)) & 1) == 0))
op->value =
result & ((unsigned long)~0 >>
(HOST_BITS_PER_LONG - num_bits));