Skip to content

Commit

Permalink
fix: decoder should clear the pointers before reslicing (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari authored Sep 19, 2024
1 parent e6386e5 commit 720cc58
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,20 @@ func (d *Decoder) reset() {
d.messages = nil
d.crc = 0
d.fileId = nil
d.developerDataIndexes = d.developerDataIndexes[:0]
d.fieldDescriptions = d.fieldDescriptions[:0]
}

// releaseTemporaryObjects releases objects that being created on a single decode process
// by stops referencing those objects so it can be released on next GC cycle.
// releaseTemporaryObjects releases objects that being created during a single decode process
// by stops referencing those objects so it can be garbage-collected on next GC cycle.
func (d *Decoder) releaseTemporaryObjects() {
d.localMessageDefinitions = [proto.LocalMesgNumMask + 1]*proto.MessageDefinition{}
d.fieldsArray = [255]proto.Field{}
d.developerFieldsArray = [255]proto.DeveloperField{}
d.messages = nil
d.developerDataIndexes = d.developerDataIndexes[:0]
for i := range d.fieldDescriptions {
d.fieldDescriptions[i] = nil
}
d.fieldDescriptions = d.fieldDescriptions[:0]
}

// CheckIntegrity checks all FIT sequences of given reader are valid determined by these following checks:
Expand Down

0 comments on commit 720cc58

Please sign in to comment.