Skip to content

Commit

Permalink
fix possible integer truncation
Browse files Browse the repository at this point in the history
Fixes #1055
  • Loading branch information
jfcg committed Sep 9, 2021
1 parent c01ab77 commit 0870776
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions array.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ func (a *Int32Array) scanBytes(src []byte) error {
} else {
b := make(Int32Array, len(elems))
for i, v := range elems {
var x int
if x, err = strconv.Atoi(string(v)); err != nil {
x, err := strconv.ParseInt(string(v), 10, 32)
if err != nil {
return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
}
b[i] = int32(x)
Expand Down
2 changes: 1 addition & 1 deletion encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func parseBytea(s []byte) (result []byte, err error) {
if len(s) < 4 {
return nil, fmt.Errorf("invalid bytea sequence %v", s)
}
r, err := strconv.ParseInt(string(s[1:4]), 8, 9)
r, err := strconv.ParseUint(string(s[1:4]), 8, 8)
if err != nil {
return nil, fmt.Errorf("could not parse bytea value: %s", err.Error())
}
Expand Down

0 comments on commit 0870776

Please sign in to comment.