Skip to content

Commit 0870776

Browse files
committed
fix possible integer truncation
Fixes #1055
1 parent c01ab77 commit 0870776

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

array.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ func (a *Int32Array) scanBytes(src []byte) error {
587587
} else {
588588
b := make(Int32Array, len(elems))
589589
for i, v := range elems {
590-
var x int
591-
if x, err = strconv.Atoi(string(v)); err != nil {
590+
x, err := strconv.ParseInt(string(v), 10, 32)
591+
if err != nil {
592592
return fmt.Errorf("pq: parsing array element index %d: %v", i, err)
593593
}
594594
b[i] = int32(x)

encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ func parseBytea(s []byte) (result []byte, err error) {
559559
if len(s) < 4 {
560560
return nil, fmt.Errorf("invalid bytea sequence %v", s)
561561
}
562-
r, err := strconv.ParseInt(string(s[1:4]), 8, 9)
562+
r, err := strconv.ParseUint(string(s[1:4]), 8, 8)
563563
if err != nil {
564564
return nil, fmt.Errorf("could not parse bytea value: %s", err.Error())
565565
}

0 commit comments

Comments
 (0)