Skip to content

Commit

Permalink
Fix overflow in expandRangeTable()
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingmutant committed Jul 5, 2021
1 parent 750f6f6 commit ce9c50f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ func expandRangeTable(t *unicode.RangeTable, key interface{}) []rune {

var ret []rune
for _, r := range t.R16 {
for i := r.Lo; i <= r.Hi; i += r.Stride {
for i := uint32(r.Lo); i <= uint32(r.Hi); i += uint32(r.Stride) {
ret = append(ret, rune(i))
}
}
for _, r := range t.R32 {
for i := r.Lo; i <= r.Hi; i += r.Stride {
for i := uint64(r.Lo); i <= uint64(r.Hi); i += uint64(r.Stride) {
ret = append(ret, rune(i))
}
}
Expand Down
12 changes: 6 additions & 6 deletions strings_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func ExampleRune() {
// '\n' '\x1b' 'A' 'a' '*'
// '0' '@' '?' '\'' '\ue05d'
// '<' '%' '!' '\u0604' 'A'
// '%' '' '~' '!' '/'
// '' '𝩇' '@' '҈' ' '
// '%' '' '~' '!' '/'
// '\u00ad' '𝪪' '@' '҈' ' '
}

func ExampleRuneFrom() {
Expand Down Expand Up @@ -67,8 +67,8 @@ func ExampleString() {
}
// Output:
// "\n߾⃝?\rA�֍"
// "\u2006𑨃"
// "A\u0603ᾢ"
// "\u2006𑰼"
// "A\u0603ᾢ"
// "+^#.[#৲"
// ""
}
Expand All @@ -95,8 +95,8 @@ func ExampleStringN() {
}
// Output:
// "\n߾⃝?\r"
// "\u2006𑨃#`\x1b"
// "A\u0603ᾢÉ"
// "\u2006𑰼#`\x1b"
// "A\u0603ᾢÉ"
// "+^#.["
// ".A<a¤"
}
Expand Down

0 comments on commit ce9c50f

Please sign in to comment.