Limit the comparison to 8 bytes or the length of the CAN frame, whatever is shorter, to avoid negative bitshifts

This commit is contained in:
Magnus Aagaard Sørensen
2022-02-21 08:23:46 +01:00
parent b03d20758a
commit a17e9ee8db
+1 -1
View File
@@ -252,7 +252,7 @@ uint64_t CANFrameModel::getCANFrameVal(int row, Column col)
return static_cast<uint64_t>(frame.payload().length());
case Column::ASCII: //sort both the same for now
case Column::Data:
for (int i = 0; i < frame.payload().length(); i++) temp += (static_cast<uint64_t>(frame.payload()[i]) << (56 - (8 * i)));
for (int i = 0; i < std::min(frame.payload().length(), 8); i++) temp += (static_cast<uint64_t>(frame.payload()[i]) << (56 - (8 * i)));
//qDebug() << temp;
return temp;
case Column::NUM_COLUMN: