Optimization-unstable code
Optimization-unstable code
Posted Dec 5, 2013 12:42 UTC (Thu) by Felix.Braun (guest, #3032)In reply to: Optimization-unstable code by jezuch
Parent article: Optimization-unstable code
The way I see it, buf + len can only be < buf if len is sufficiently big to wrap around the address space. Wouldn't it be much more useful to check for a buffer overflow like this instead?char *buf = ...; unsigned int len = ...; if (buf + len < buf) /* overflow check */
if (buf + len >= &len) ...