Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion message.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ func (e *Encoder) Encode(m *Message) error {
return annotatef(err, "encode")
}
n := len(s.data)
if n > int(maxSegmentSize) {
if int64(n) > int64(maxSegmentSize) {
return errorf("encode: segment %d too large", i)
}
e.hdrbuf = appendUint32(e.hdrbuf, uint32(Size(n)/wordSize))
Expand Down
4 changes: 3 additions & 1 deletion message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io"
"math"
"testing"
"testing/quick"

Expand Down Expand Up @@ -873,6 +874,7 @@ func TestFirstSegmentMessage_MultiSegment(t *testing.T) {
func TestNextAlloc(t *testing.T) {
const max32 = 1<<31 - 8
const max64 = 1<<63 - 8
const is64bit = int64(maxInt) == math.MaxInt64
tests := []struct {
name string
curr int64
Expand All @@ -885,7 +887,7 @@ func TestNextAlloc(t *testing.T) {
{name: "first word, unaligned curr", curr: 13, max: max64, req: 8, ok: true},
{name: "second word", curr: 8, max: max64, req: 8, ok: true},
{name: "one byte pads to word", curr: 8, max: max64, req: 1, ok: true},
{name: "max size", curr: 0, max: max64, req: 0xfffffff8, ok: true},
{name: "max size", curr: 0, max: max64, req: 0xfffffff8, ok: is64bit},
{name: "max size + 1", curr: 0, max: max64, req: 0xfffffff9, ok: false},
{name: "max req", curr: 0, max: max64, req: 0xffffffff, ok: false},
{name: "max curr, request 0", curr: max64, max: max64, req: 0, ok: true},
Expand Down