BAEL-1913 fix possible index out of bound

This commit is contained in:
nnhai1991@gmail.com 2018-11-18 00:16:35 +08:00
parent 8e5a2ba1fe
commit d2d77c56f8
1 changed files with 1 additions and 1 deletions

View File

@ -52,7 +52,7 @@ class RandomStringUnitTest {
random.nextBytes(bytes)
var randomString = (0..bytes.size - 1).map { i ->
charPool.get((bytes[i] and 0xFF.toByte() and charPool.size.toByte()).toInt())
charPool.get((bytes[i] and 0xFF.toByte() and (charPool.size-1).toByte()).toInt())
}.joinToString("")
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))