Skip to content

Commit

Permalink
Merge pull request json-iterator#450 from fantastao/fix_any_str_panic
Browse files Browse the repository at this point in the history
fix any str ToInt64 ToUint64 panic
  • Loading branch information
AllenX2018 authored Mar 26, 2020
2 parents 6203136 + ef28dc1 commit 5b034bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions any_str.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (any *stringAny) ToInt64() int64 {

flag := 1
startPos := 0
endPos := 0
if any.val[0] == '+' || any.val[0] == '-' {
startPos = 1
}
Expand All @@ -73,6 +72,7 @@ func (any *stringAny) ToInt64() int64 {
flag = -1
}

endPos := startPos
for i := startPos; i < len(any.val); i++ {
if any.val[i] >= '0' && any.val[i] <= '9' {
endPos = i + 1
Expand All @@ -98,7 +98,6 @@ func (any *stringAny) ToUint64() uint64 {
}

startPos := 0
endPos := 0

if any.val[0] == '-' {
return 0
Expand All @@ -107,6 +106,7 @@ func (any *stringAny) ToUint64() uint64 {
startPos = 1
}

endPos := startPos
for i := startPos; i < len(any.val); i++ {
if any.val[i] >= '0' && any.val[i] <= '9' {
endPos = i + 1
Expand Down

0 comments on commit 5b034bb

Please sign in to comment.