Skip to content

Commit

Permalink
Whatever CodeQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Jul 13, 2022
1 parent 1076e06 commit 14aa2d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion s2/decode.go
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"io"
"io/ioutil"
"math"
"runtime"
"sync"
)
Expand Down Expand Up @@ -719,7 +720,11 @@ func (r *Reader) Skip(n int64) error {
// decoded[i:j] contains decoded bytes that have not yet been passed on.
left := int64(r.j - r.i)
if left >= n {
r.i += int(n)
tmp := int64(r.i) + n
if tmp > math.MaxInt32 {
return errors.New("s2: internal overflow in skip")
}
r.i += int(tmp)
return nil
}
n -= int64(r.j - r.i)
Expand Down

0 comments on commit 14aa2d7

Please sign in to comment.