Fixed segfault in reg_read when no datatype is specified.
authorFlorian Pose <fp@igh-essen.com>
Thu, 15 Apr 2010 12:33:48 +0200
changeset 1893 9a136c0c30a2
parent 1892 0c254f0e7f7d
child 1894 b7799f615dca
Fixed segfault in reg_read when no datatype is specified.
tool/DataTypeHandler.cpp
--- a/tool/DataTypeHandler.cpp	Thu Apr 15 12:31:12 2010 +0200
+++ b/tool/DataTypeHandler.cpp	Thu Apr 15 12:33:48 2010 +0200
@@ -269,12 +269,19 @@
         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');