comparison lib/unictype/categ_of.c @ 40210:44073ad4207f

unictype/numeric: Fix undefined behaviour. Reported by Jeffrey Walton <noloader@gmail.com>. * lib/unictype/numeric.c (uc_numeric_value): Avoid undefined behaviour on shift overflow, caught by "gcc -fsanitize=undefined". * lib/unictype/bidi_of.c (uc_bidi_class): Add cast, for clarity. * lib/unictype/categ_of.c (lookup_withtable): Likewise. * lib/unictype/joininggroup_of.c (uc_joining_group): Likewise.
author Bruno Haible <bruno@clisp.org>
date Fri, 08 Mar 2019 19:17:37 +0100
parents b06060465f09
children
comparison
equal deleted inserted replaced
40209:c43e83386661 40210:44073ad4207f
37 if (lookup2 >= 0) 37 if (lookup2 >= 0)
38 { 38 {
39 unsigned int index3 = ((uc & category_header_4) + lookup2) * 5; 39 unsigned int index3 = ((uc & category_header_4) + lookup2) * 5;
40 /* level3 contains 5-bit values, packed into 16-bit words. */ 40 /* level3 contains 5-bit values, packed into 16-bit words. */
41 unsigned int lookup3 = 41 unsigned int lookup3 =
42 ((u_category.level3[index3>>4] 42 (((unsigned int) u_category.level3[index3>>4]
43 | ((unsigned int) u_category.level3[(index3>>4)+1] << 16)) 43 | ((unsigned int) u_category.level3[(index3>>4)+1] << 16))
44 >> (index3 % 16)) 44 >> (index3 % 16))
45 & 0x1f; 45 & 0x1f;
46 46
47 return lookup3; 47 return lookup3;