Skip to content

Commit

Permalink
Fix buf size in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Jan 23, 2025
1 parent 67bee55 commit ca0af15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rpc_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,9 @@ func encode(c baseCodec, msg any) (mem.BufferSlice, error) {
if err != nil {
return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error())
}
if uint(b.Len()) > math.MaxUint32 {
if bufSize := uint(b.Len()); bufSize > math.MaxUint32 {
b.Free()
return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", len(b))
return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", bufSize)
}
return b, nil
}
Expand Down

0 comments on commit ca0af15

Please sign in to comment.