Fixed possible null pointer dereference in ethercat tool. redundancy
authorFlorian Pose <fp@igh-essen.com>
Wed, 04 Jan 2012 15:57:10 +0100
branchredundancy
changeset 2308 f842ca3436ba
parent 2307 5ccf44ed4b13
child 2309 b0ddf0ea0a60
Fixed possible null pointer dereference in ethercat tool.
tool/DataTypeHandler.cpp
--- a/tool/DataTypeHandler.cpp	Wed Jan 04 14:07:02 2012 +0100
+++ b/tool/DataTypeHandler.cpp	Wed Jan 04 15:57:10 2012 +0100
@@ -54,7 +54,7 @@
         )
 {
     const DataType *d;
-    
+
     for (d = dataTypes; d->name; d++)
         if (str == d->name)
             return d;
@@ -86,7 +86,7 @@
 const DataTypeHandler::DataType *DataTypeHandler::findDataType(uint16_t code)
 {
     const DataType *d;
-    
+
     for (d = dataTypes; d->name; d++)
         if (code == d->code)
             return d;
@@ -286,7 +286,7 @@
 
     o << setfill('0');
 
-    switch (type->code) {
+    switch (typeCode) {
         case 0x0001: // bool
             {
                 int val = (int) *(int8_t *) data;
@@ -378,7 +378,7 @@
             {
                 int8_t val = *(uint8_t *) data;
                 int8_t smval = val < 0 ? (val & 0x7f) * -1 : val;
-                
+
                 o << "0x" << hex << setw(2) << (int) val
                     << " " << dec << (int) smval << endl;
             }
@@ -387,7 +387,7 @@
             {
                 int16_t val = le16_to_cpup(data);
                 int16_t smval = val < 0 ? (val & 0x7fff) * -1 : val;
-                
+
                 o << "0x" << hex << setw(4) << val
                     << " " << dec << smval << endl;
             }
@@ -396,7 +396,7 @@
             {
                 int32_t val = le32_to_cpup(data);
                 int32_t smval = val < 0 ? (val & 0x7fffffffUL) * -1 : val;
-                
+
                 o << "0x" << hex << setw(8) << val
                     << " " << dec << smval << endl;
             }
@@ -406,7 +406,7 @@
                 int64_t val = le64_to_cpup(data);
                 int64_t smval =
                     val < 0 ? (val & 0x7fffffffffffffffULL) * -1 : val;
-                
+
                 o << "0x" << hex << setw(16) << val
                     << " " << dec << smval << endl;
             }