alternator/base64: fix harmless integer overflow

We assign 255 to an int8_t, but 255 isn't representable as
an int8_t. Change to the bitwise equivalent but representable -1.

Found by clang.
This commit is contained in:
Avi Kivity
2020-09-19 18:46:35 +03:00
parent cf3e779180
commit 2d33a3f73c

View File

@@ -38,7 +38,7 @@ public:
base64_chars() {
static_assert(sizeof(to) == 64 + 1);
for (int i = 0; i < 255; i++) {
from[i] = 255; // signal invalid character
from[i] = -1; // signal invalid character
}
for (int i = 0; i < 64; i++) {
from[(unsigned) to[i]] = i;