Skip to content

Commit d2d77c5

Browse files
nnhai1991@gmail.comnnhai1991@gmail.com
authored andcommitted
BAEL-1913 fix possible index out of bound
1 parent 8e5a2ba commit d2d77c5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎core-kotlin/src/test/kotlin/com/baeldung/random/RandomStringUnitTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class RandomStringUnitTest {
5252
random.nextBytes(bytes)
5353

5454
var randomString = (0..bytes.size - 1).map { i ->
55-
charPool.get((bytes[i] and 0xFF.toByte() and charPool.size.toByte()).toInt())
55+
charPool.get((bytes[i] and 0xFF.toByte() and (charPool.size-1).toByte()).toInt())
5656
}.joinToString("")
5757

5858
assert(randomString.matches(Regex(ALPHANUMERIC_REGEX)))

0 commit comments

Comments
 (0)