Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Double free in FIT SDK cpp encoder

Rank

Total Posts: 23

Joined 2019-05-06

PM

On FIT SDK 20.66.00, I have noticed that adding a new record with developer fields to FIT file can cause double memory free issue.

DeveloperFieldDefinition class contain raw pointers, but does not define custom copy assignment operator to avoid memberwise copy of pointers.
This leads to double free of the same pointer address in void Encode::Write( const MesgDefinition& mesgDef ) function when existing message definition is destructed at lastMesgDefinition[mesgDef.GetLocalNum()] = mesgDef line.
void Encode::Write( const MesgDefinitionmesgDef )
{
    
if ( !file )
        return;

    if ( !
validator.ValidateMesgDefnmesgDef ) )
        return;

    
dataSize += mesgDef.Write( *file );
    
lastMesgDefinition[mesgDef.GetLocalNum()mesgDef;

Attaching valgrind logs which provide detailed explanation of this issue.      

File Attachments

Rank

Total Posts: 23

Joined 2019-05-06

PM

Can somebody from FIT SDK dev team comment on this issue?