mapbox / protozero

Minimalist protocol buffer decoder and encoder in C++
BSD 2-Clause "Simplified" License
292 stars 78 forks source link

clang sanitizer errors (signed <-> unsigned) #100

Closed artemp closed 4 years ago

artemp commented 4 years ago

Issue

/include/protozero/varint.hpp:57:33: runtime error: implicit conversion from type 'int8_t' (aka 'signed char') of value -128 (8-bit, signed) to type 'unsigned int' changed the value to 4294967168 (32-bit, unsigned)
/include/protozero/varint.hpp:91:27: runtime error: implicit conversion from type 'char' of value -79 (8-bit, signed) to type 'unsigned int' changed the value to 4294967217 (32-bit, unsigned)

Fix

57c57
<                 val |= uint64_t(*p++ & 0x7fu) << shift;
---
>                 val |= uint64_t(*p++ & 0x7f) << shift;
91c91
<     if (end != *data && ((**data & 0x80u) == 0)) {
---
>     if (end != *data && ((**data & 0x80) == 0)) {

/cc @joto @springmeyer

artemp commented 4 years ago

This has been fixed in 1.6.8 closing