Module 9 · Arrays
Bug Gallery: Out of Bounds and the Silent Write
ProReading
Bob needs ten boxes holding 1 to 10. He counts from 1, like every calendar he owns, and fills a[1] to a[10]. The Playground says Success and prints 0 1 2 3 4 5 6 7 8 9. Bob calls it a cosmetic issue.
Checking what this lesson needs for you…
What is inside Bug Gallery: Out of Bounds and the Silent Write
- One write past the end, and a Success badge
- When the compiler deletes the bad write
- A few boxes further, then far past the end
- Reading past the end: garbage that looks like an answer
- The off-by-one at the last index
- The array nobody filled
- The wrong count passed to a function
- Maria's bug: a countdown that cannot go below zero
- What GCC 12 says, and what it cannot see
- AddressSanitizer: a check on every box
- The names the security world uses: CWE-787, CWE-125, Heartbleed
- The array checklist