3 ms·
Maybe I am not awake yet (just rolled out of bed), but if new->format is allocated to 4 bytes, then new->format[4] = '\0'; is out of bounds, no?
by danieldk 11y ago
Maybe I am not awake yet (just rolled out of bed), but if new->format is allocated to 4 bytes, then
new->format[4] = '\0';
is out of bounds, no?
- _RPM 11y agoYes it was. Good catch. The size of the buffer is 4, so the last byte would be located at 4-1 = index 3. Because we're 0 based...Wow can't believe I did that. it's 12:30 AM here and I've had a few beers tonight. It's common to allocate your size needed plus 1 for the NULL byte. But this programmer only allocates 4 bytes.. with no thought of the NULL byte at the end.