From a17e9ee8dbcff365de7b8897ec27ebc00df68247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Aagaard=20S=C3=B8rensen?= Date: Mon, 21 Feb 2022 08:23:46 +0100 Subject: [PATCH] Limit the comparison to 8 bytes or the length of the CAN frame, whatever is shorter, to avoid negative bitshifts --- canframemodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canframemodel.cpp b/canframemodel.cpp index e053044..80aeaaa 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -252,7 +252,7 @@ uint64_t CANFrameModel::getCANFrameVal(int row, Column col) return static_cast(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(frame.payload()[i]) << (56 - (8 * i))); + for (int i = 0; i < std::min(frame.payload().length(), 8); i++) temp += (static_cast(frame.payload()[i]) << (56 - (8 * i))); //qDebug() << temp; return temp; case Column::NUM_COLUMN: