summaryrefslogtreecommitdiff
path: root/upb/pb/varint.int.h
diff options
context:
space:
mode:
authorEsun Kim <veblush@google.com>2019-07-31 14:20:46 -0700
committerEsun Kim <veblush@google.com>2019-07-31 14:20:46 -0700
commitbc8b1a8f90706c7178fc0a128a7a791b85bbe88f (patch)
treec9732dec7f92679619dbb1589318b3f369f1f646 /upb/pb/varint.int.h
parent7e7cb5f831a97655a2d28ed49b485e14a9dd8188 (diff)
Fixed UBSAN issues
Diffstat (limited to 'upb/pb/varint.int.h')
-rw-r--r--upb/pb/varint.int.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/upb/pb/varint.int.h b/upb/pb/varint.int.h
index ddda694..ff1ca66 100644
--- a/upb/pb/varint.int.h
+++ b/upb/pb/varint.int.h
@@ -46,8 +46,12 @@ UPB_INLINE int32_t upb_zzdec_32(uint32_t n) {
UPB_INLINE int64_t upb_zzdec_64(uint64_t n) {
return (n >> 1) ^ -(int64_t)(n & 1);
}
-UPB_INLINE uint32_t upb_zzenc_32(int32_t n) { return (n << 1) ^ (n >> 31); }
-UPB_INLINE uint64_t upb_zzenc_64(int64_t n) { return (n << 1) ^ (n >> 63); }
+UPB_INLINE uint32_t upb_zzenc_32(int32_t n) {
+ return ((uint32_t)n << 1) ^ (n >> 31);
+}
+UPB_INLINE uint64_t upb_zzenc_64(int64_t n) {
+ return ((uint64_t)n << 1) ^ (n >> 63);
+}
/* Decoding *******************************************************************/
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback