[#51] *: Do not panic in StableSize()

After #49 it can be called on nil structures.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-08-02 10:55:05 +03:00
parent 3072090c77
commit 964c3edb3f
2 changed files with 20 additions and 0 deletions

View file

@ -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)