...
To correct this example, the size of buf
can be directly added to buf
and used as an upper bound. The integer literal is scaled to the size of an integer and the upper bound of buf
is appropriately correctly checked.
Code Block | ||
---|---|---|
| ||
int buf[1024]; int *b = buf; while (havedata() && b < buf+1024) { *b++ = parseint(getdata()); } |
...