fixed an endless loop when length of chars is a divisor of 256

This commit is contained in:
Oleg Ivanov 2014-08-09 23:08:44 +10:00
parent bc4af7603a
commit 1b691aeab2
2 changed files with 26 additions and 8 deletions

View file

@ -56,7 +56,7 @@ func NewLenChars(length int, chars []byte) string {
panic("error reading from random source: " + err.Error())
}
for _, c := range r {
if c >= maxrb {
if c > maxrb {
// Skip this number to avoid modulo bias.
continue
}