diff --git a/common/util.cc b/common/util.cc index 55a8b1fb3e851e..2914f6bcbc6269 100644 --- a/common/util.cc +++ b/common/util.cc @@ -214,9 +214,9 @@ std::string hexdump(const uint8_t* in, const size_t size) { } std::string random_string(std::string::size_type length) { - const char* chrs = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const std::string chrs = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; std::mt19937 rg{std::random_device{}()}; - std::uniform_int_distribution pick(0, sizeof(chrs) - 2); + std::uniform_int_distribution pick(0, chrs.length() - 1); std::string s; s.reserve(length); while (length--) {