From 3072090c7729dd3c2727593ff099b05989f9b265 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 2 Aug 2023 10:46:01 +0300 Subject: [PATCH] [#51] protogen: Do not panic in StableSize() Refs https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/554 . Signed-off-by: Evgenii Stratonikov --- util/protogen/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/util/protogen/main.go b/util/protogen/main.go index 99f5b7b..fe89fbf 100644 --- a/util/protogen/main.go +++ b/util/protogen/main.go @@ -59,6 +59,7 @@ func emitMessage(g *protogen.GeneratedFile, msg *protogen.Message) { g.P("//") g.P("// Structures with the same field values have the same binary size.") g.P("func (x *", msg.GoIdent.GoName, ") StableSize() (size int) {") + g.P("if x == nil { return 0 }") if len(fs) != 0 { for _, f := range fs { if f.Desc.IsList() && marshalers[f.Desc.Kind()].RepeatedDouble {