muktihari / fit

A FIT SDK for decoding and encoding Garmin FIT files in Go supporting FIT Protocol V2.
BSD 3-Clause "New" or "Revised" License
24 stars 2 forks source link

fix: decoder should clear the pointers before reslicing #460

Closed muktihari closed 1 week ago

muktihari commented 1 week ago

Previously, d.fieldDescriptions was resliced on reset, resulting d.releaseTemporaryObjects to do nothing regarding that field so the pointers (if any) will be keep until next decoding process reaching the previous slice index then replacing the value.

In general, this should not be a problem since the values will be replaced anyway when we do decode again, and the pointer will eventually be released at some point or when the decoder is no longer used (garbage-collected), but it becomes nondeterministic, so let's fix it.

We can move the resetting of d.fieldDescriptions and d.developerDataIndexes to d.releaseTemporaryObjects instead of in d.reset, since these fields only changes during decoding messages.

codecov-commenter commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.94%. Comparing base (e6386e5) to head (f148c37).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #460 +/- ## ======================================= Coverage 99.94% 99.94% ======================================= Files 42 42 Lines 3697 3697 ======================================= Hits 3695 3695 Misses 2 2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.