Eliminate undefined behavior of bit shifting signed int.

This commit is contained in:
Chad Fraleigh 2023-07-09 15:09:17 -07:00
parent b8f998f76a
commit 47dc5591b9
No known key found for this signature in database
GPG Key ID: 2415C39758458A8F

View File

@ -298,7 +298,7 @@ namespace data
size_t ByteStreamToBase32 (const uint8_t * inBuf, size_t len, char * outBuf, size_t outLen) size_t ByteStreamToBase32 (const uint8_t * inBuf, size_t len, char * outBuf, size_t outLen)
{ {
size_t ret = 0, pos = 1; size_t ret = 0, pos = 1;
int bits = 8, tmp = inBuf[0]; unsigned int bits = 8, tmp = inBuf[0];
while (ret < outLen && (bits > 0 || pos < len)) while (ret < outLen && (bits > 0 || pos < len))
{ {
if (bits < 5) if (bits < 5)