Tue 18 Jan 2011 07:20:29 AM UTC, original submission:
Methods devoted to std::wstring handling (HLA 1516-2000 compatible methods) has some bugs.
-----------------------------
1) RTI1516Ambassador.cpp:125
// old code does not allow to pass null bytes due to selected std::string constructor.
/char buf = (char*) calloc(varLengthData.size() + 1, sizeof(char));
memcpy(buf, varLengthData.data(), varLengthData.size());
std::string retVal(buf);
free(buf);*/
// proposed fix
std::string retVal( (char*)varLengthData.data(), varLengthData.size() );
-----------------------------
2) BasicMessage.cc:126
// original code reads string instantly to the label message attribute, and it does not affect wLabel attribute value. Unchanged wLabel and wTag result in errors in callback parameters.
if (_isLabelled) {
msgBuffer.read_string(label);
}
_isTagged = msgBuffer.read_bool();
if (_isTagged) {
msgBuffer.read_string(tag);
}
// proposed fix
if (_isLabelled) {
std::string label;
msgBuffer.read_string(label);
setLabel( label );
}
_isTagged = msgBuffer.read_bool();
if (_isTagged) {
msgBuffer.read_string(tag);
wTag = std::wstring( tag.begin(), tag.end() );
}
|