out of bound write. there is an overrun error.
> #define FLOORSNUMBER 128
> #define ILAFLOORSNUMBER 40
> #else
> #define ILAFLOORSNUMBER 40
>
> uint8 downCallSide[ILAFLOORSNUMBER]; extern uint16
> callLightTimerAside[FLOORSNUMBER]; extern uint16
> callLightTimerBside[FLOORSNUMBER];
for(i = 0;i <= FLOORSNUMBER;i )
{
**CID 18019 (#1 of 3): Out-of-bounds write (OVERRUN)
overrun-local: Overrunning array ilaByPass.downCallSide of 40 bytes at byte offset 128 using index i (which evaluates to 128)**
ilaByPass.downCallSide[i] = OFFSTATE;
#ifndef NA
**CID 17746 (#1 of 3): Out-of-bounds write (OVERRUN)**
**overrun-local: Overrunning array callLightTimerAside of 128 2-byte elements at element index 128 (byte offset 257) using index i (which evaluates to 128).**
callLightTimerAside[i] = OFFSTATE;
i understand that there is an overrun when we try to downcallside[i] since the value of i goes up to 128 and the size of downcallside is only 40. how do i resolve it?
and
for callLightTimerAside[i], the size appears to be the same as the floornumber, but there is still an overrun.
CodePudding user response:
This is some weird looking C. Not really sure what is going on, but
for(i = 0;i <= FLOORSNUMBER;i )
This is almost certainly a mistake. You loop through indicies 0-128, while the arrays you declare are of length 128 with indicies 0-127. The 128th index does not exist.
Try
for (i = 0; i < FLOORSNUMBER; i )