]> granicus.if.org Git - onig/commitdiff
Fix two ubsan warnings
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Sep 2019 22:49:32 +0000 (00:49 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Sep 2019 22:50:13 +0000 (00:50 +0200)
src/regint.h
src/regparse.c

index fe4ee9bbb2a31e86ab0b1b73898cb000cc4b65cb..1b58e024bcf2a9f6d75eece6537c38307ffb6766 100644 (file)
@@ -385,7 +385,7 @@ typedef Bits*          BitSetRef;
 } while (0)
 
 #define BS_ROOM(bs,pos)            (bs)[pos / BITS_IN_ROOM]
-#define BS_BIT(pos)                (1 << (pos % BITS_IN_ROOM))
+#define BS_BIT(pos)                (1u << (pos % BITS_IN_ROOM))
 
 #define BITSET_AT(bs, pos)         (BS_ROOM(bs,pos) & BS_BIT(pos))
 #define BITSET_SET_BIT(bs, pos)     BS_ROOM(bs,pos) |= BS_BIT(pos)
index 49076d599a0d8009282d783da9cd58d4ad41dd86..e506f841d2dc2a20ce6dc65416682d488437b49c 100644 (file)
@@ -467,14 +467,14 @@ static int
 str_end_hash(st_str_end_key* x)
 {
   UChar *p;
-  int val = 0;
+  unsigned val = 0;
 
   p = x->s;
   while (p < x->end) {
-    val = val * 997 + (int )*p++;
+    val = val * 997 + (unsigned )*p++;
   }
 
-  return val + (val >> 5);
+  return (int) (val + (val >> 5));
 }
 
 extern hash_table_type*