mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-05 13:08:58 +00:00
Perform nil check on string fields when packing (#7719)
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -14,7 +14,10 @@ type StatT struct {
|
||||
|
||||
func (t *StatT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
idOffset := builder.CreateString(t.Id)
|
||||
idOffset := flatbuffers.UOffsetT(0)
|
||||
if t.Id != "" {
|
||||
idOffset = builder.CreateString(t.Id)
|
||||
}
|
||||
StatStart(builder)
|
||||
StatAddId(builder, idOffset)
|
||||
StatAddVal(builder, t.Val)
|
||||
|
||||
Reference in New Issue
Block a user