Skip to content

Commit

Permalink
fit: int64 overflow for remaining bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Dec 28, 2023
1 parent 8ddeba9 commit 4a9ad07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion api/session/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package session

import (
"fmt"
"math"
"net/http"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -194,7 +195,12 @@ func HandlerAddSession(ctx *context.Context) gin.HandlerFunc {
return
}

remainingBytes = alloc.GrantedBytes.Sub(alloc.UtilisedBytes).Int64()
diff := alloc.GrantedBytes.Sub(alloc.UtilisedBytes)
if diff.IsInt64() {
remainingBytes = diff.Int64()
} else {
remainingBytes = math.MaxInt64
}
}

var items []types.Session
Expand Down
2 changes: 1 addition & 1 deletion types/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewResponse(err interface{}, res interface{}) *Response {
}

func NewResponseError(code int, v interface{}) *Response {
message := ""
message := "unknown error"
if m, ok := v.(string); ok {
message = m
} else if m, ok := v.(error); ok {
Expand Down

0 comments on commit 4a9ad07

Please sign in to comment.