diff --git a/netmap/marshal.go b/netmap/marshal.go index bf559ce..4f2c1ce 100644 --- a/netmap/marshal.go +++ b/netmap/marshal.go @@ -65,6 +65,10 @@ func (f *Filter) StableMarshal(buf []byte) []byte { } func (f *Filter) StableSize() (size int) { + if f == nil { + return 0 + } + size += protoutil.StringSize(nameFilterField, f.name) size += protoutil.StringSize(keyFilterField, f.key) size += protoutil.EnumSize(opFilterField, int32(f.op)) @@ -101,6 +105,10 @@ func (s *Selector) StableMarshal(buf []byte) []byte { } func (s *Selector) StableSize() (size int) { + if s == nil { + return 0 + } + size += protoutil.StringSize(nameSelectorField, s.name) size += protoutil.UInt32Size(countSelectorField, s.count) size += protoutil.EnumSize(countSelectorField, int32(s.clause)) @@ -132,6 +140,10 @@ func (r *Replica) StableMarshal(buf []byte) []byte { } func (r *Replica) StableSize() (size int) { + if r == nil { + return 0 + } + size += protoutil.UInt32Size(countReplicaField, r.count) size += protoutil.StringSize(selectorReplicaField, r.selector) @@ -173,6 +185,10 @@ func (p *PlacementPolicy) StableMarshal(buf []byte) []byte { } func (p *PlacementPolicy) StableSize() (size int) { + if p == nil { + return 0 + } + for i := range p.replicas { size += protoutil.NestedStructureSize(replicasPolicyField, &p.replicas[i]) } diff --git a/status/marshal.go b/status/marshal.go index 1868a43..2908e0d 100644 --- a/status/marshal.go +++ b/status/marshal.go @@ -30,6 +30,10 @@ func (x *Detail) StableMarshal(buf []byte) []byte { } func (x *Detail) StableSize() (size int) { + if x == nil { + return 0 + } + size += protoutil.UInt32Size(detailIDFNum, x.id) size += protoutil.BytesSize(detailValueFNum, x.val)