Hi,
Klocwork reports an error of:-
"ABR – Buffer overflow, array index of 'oidsp' may be out of bounds. Array 'oidsp' of size 64 may use index value(s) -2..-1."
For this line:-
if (check_index_lower_legality (len,-1))
{
oidsp[len-1] = specProb;
}
When check_index_lower_legality is:-
bool check_index_lower_legality (int index, int offset)
/**
* This function checks that the index with the offset isn't
* below zero.
* If it is - returns 0 ;
* If isn't - returns 1 ;
**/
{
if ( (index + offset )<0) {
return 0;
}
return 1 ;
}
However no bug when check_index_lower_legality
is:-
(which is by the way an incorrect answer , as for the offset values of -2 or -1 there will be a real error on runtime.
bool check_index_lower_legality (int index, int offset)
/**
* This function checks that the index with the offset isn't
* below zero.
* If it is - returns 0 ;
* If isn't - returns 1 ;
**/
{
if (index <=0) {
return 0;
}
return 1;
}
Any ideas?