Fixed segfault in reg_read when no datatype is specified.

This commit is contained in:
Florian Pose 2010-04-15 12:33:48 +02:00
parent f5ffc1f386
commit c59bad0d80
1 changed files with 13 additions and 6 deletions

View File

@ -269,12 +269,19 @@ void DataTypeHandler::outputData(
size_t dataSize
)
{
if (type->byteSize && dataSize != type->byteSize) {
stringstream err;
err << "Data type mismatch. Expected " << type->name
<< " with " << type->byteSize << " byte, but got "
<< dataSize << " byte.";
throw SizeException(err.str());
uint16_t typeCode;
if (type) {
if (type->byteSize && dataSize != type->byteSize) {
stringstream err;
err << "Data type mismatch. Expected " << type->name
<< " with " << type->byteSize << " byte, but got "
<< dataSize << " byte.";
throw SizeException(err.str());
}
typeCode = type->code;
} else {
typeCode = 0xffff; // raw data
}
o << setfill('0');