Menu

#2 Bugfix for marshalling/unmarshalling of VariableDatum

open
nobody
None
5
2012-10-30
2007-12-20
Anonymous
No

Hello,

first of all great thanks to all contibutors to this great library!

I am using the c++ open-dis library and have recognized a bug at the marhalling and unmarshalling of the VariableDatum DIS-Record.

Here are the manual fixes of the c++ code (at the for-loop the number of bits instead of bytes were used) - hopefully you may integrate it into the code-generation though XMLPG:

void VariableDatum::marshal(DataStream& dataStream) const
{
dataStream << _variableDatumID;
dataStream << ( unsigned int )_variableDatums.size();

 //DK: Fixed bit/byte number error in for-loop which caused crashed
 for(size_t idx = 0; idx < _variableDatums.size() / 8; idx+=8)
 {
    EightByteChunk x = _variableDatums[idx];
    x.marshal(dataStream);
 }

}

void VariableDatum::unmarshal(DataStream& dataStream)
{
dataStream >> _variableDatumID;
dataStream >> _variableDatumLength;

 _variableDatums.clear();

//DK: Fixed bit/byte number error in for-loop which caused crashed
 for(size_t idx = 0; idx < _variableDatumLength / 8; idx+=8)
 {
    EightByteChunk x;
    x.unmarshal(dataStream);
    _variableDatums.push_back(x);
 }

}

Kind regards,
Daniel Kallfass

Discussion

  • John K Grant

    John K Grant - 2008-03-12

    Logged In: YES
    user_id=457760
    Originator: NO

    Has this been fixed in the source code generator so that both Java and C++ are correct? -John

     
  • Nobody/Anonymous

    Logged In: NO

    Hi,

    It seams that a similar problem exist in the java code. Since variableDatums is a List the variableDatums.size() will return the number of items in the list and not the number of bits in the list.

    Replacing "dos.writeInt( (int)variableDatums.size());" with "dos.writeInt( (int)variableDatums.size()*64);" should do the trick.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.