containerOutOfBounds - Out of bounds access in expression 'data[0]' because 'data' is empty.
This error makes sense as 'qData' may be empty, hence 'data' will be empty.
The concern is with the line further down
'if ( (data.length() >= 4) || (data[1] & 0xf0) == 0 )'
No error was raised here even though data[1] will also be out of bounds if the length of data is less than 4.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a warning when accessing data[3], since it directly contradicts the first condition. data[1] could be safe even when data.length() is less than four.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, an error was picked up in the below code when running cppcheck 2.6.
containerOutOfBounds - Out of bounds access in expression 'data[0]' because 'data' is empty.
This error makes sense as 'qData' may be empty, hence 'data' will be empty.
The concern is with the line further down
'if ( (data.length() >= 4) || (data[1] & 0xf0) == 0 )'
No error was raised here even though data[1] will also be out of bounds if the length of data is less than 4.
Reduced example:
There is a warning when accessing
data[3]
, since it directly contradicts the first condition.data[1]
could be safe even whendata.length()
is less than four.