Derive maximum base from number of digits instead of hardcoding

This commit is contained in:
Juhani Krekelä 2022-11-20 20:04:39 +02:00
parent fd87faddeb
commit 341f08d704
1 changed files with 1 additions and 1 deletions

View File

@ -9,7 +9,7 @@ static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
bool baseconv(char outbuf[], size_t bufsize, unsigned base, uintmax_t num) {
// Supported bases are 2 to 36 inclusive (though it could be higher
// if our digits string was longer
if (base < 2 || base > 36)
if (base < 2 || base > sizeof(digits))
return false;
// Longest possible converted string is base-2, where we produce one