Hi ,
I'm working on a code, and I'm using klocwork for static analysis, which is suspicious of array bound error.
I'm working on a code, and I'm using klocwork for static analysis, which is suspicious of array bound error.
ptr->array_temps[ptr->numberInPool++] = primary->array_temp : loop
numberInPool is increased regardless of the loop , so if this should be protected, if yes, how?
C:
void Handler(Data_t *instance)
{
structanother *primary;
Pool_t *ptr;
Pool_t *prev;
primary = (structanother *) instance->recvMsgP;
#ifndef X
if (instance->myAparray_temp == value1)
#endif
{
ptr = instance->instance_internal;
prev = NULL;
while((ptr) && (ptr->numberInPool == POOL_SIZE)) // The value of poolsize is 10
{
prev = ptr;
ptr = ptr->next;
}
if (ptr)
{
/* Do nothing */
}
else
{
ptr = memalloc(sizeof(Pool_t));
if (prev)
{
prev->next = ptr;
}
else
{
instance->instance_internal = ptr;
}
}
ptr->array_temps[ptr->numberInPool++] = primary->array_temp; // Error line - Is there possiblity of array bound error?
instance->numberOfinstance_internal++;
}
Last edited by a moderator: