diff --git a/compiler-rt/lib/fuzzer/FuzzerUtil.cpp b/compiler-rt/lib/fuzzer/FuzzerUtil.cpp index 87180d1ea85d5..7eecb68d0729d 100644 --- a/compiler-rt/lib/fuzzer/FuzzerUtil.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerUtil.cpp @@ -161,20 +161,21 @@ std::string Base64(const Unit &U) { size_t i = 0, j = 0; for (size_t n = U.size() / 3 * 3; i < n; i += 3, j += 4) { - uint32_t x = (U[i] << 16) | (U[i + 1] << 8) | U[i + 2]; + uint32_t x = ((unsigned char)U[i] << 16) | ((unsigned char)U[i + 1] << 8) | + (unsigned char)U[i + 2]; Buffer[j + 0] = Table[(x >> 18) & 63]; Buffer[j + 1] = Table[(x >> 12) & 63]; Buffer[j + 2] = Table[(x >> 6) & 63]; Buffer[j + 3] = Table[x & 63]; } if (i + 1 == U.size()) { - uint32_t x = (U[i] << 16); + uint32_t x = ((unsigned char)U[i] << 16); Buffer[j + 0] = Table[(x >> 18) & 63]; Buffer[j + 1] = Table[(x >> 12) & 63]; Buffer[j + 2] = '='; Buffer[j + 3] = '='; } else if (i + 2 == U.size()) { - uint32_t x = (U[i] << 16) | (U[i + 1] << 8); + uint32_t x = ((unsigned char)U[i] << 16) | ((unsigned char)U[i + 1] << 8); Buffer[j + 0] = Table[(x >> 18) & 63]; Buffer[j + 1] = Table[(x >> 12) & 63]; Buffer[j + 2] = Table[(x >> 6) & 63];