...
In this compliant solution, p is declared with the same scope as c_str, preventing p from taking on an indeterminate value outside of this_is_OK().:
| Code Block | ||||
|---|---|---|---|---|
| ||||
void this_is_OK(void) {
const char c_str[] = "Everything OK";
const char *p = c_str;
/* ... */
}
/* p is inaccessible outside the scope of string c_str */
|
...
Bibliography
| [Coverity 2007] | |
| [ISO/IEC 9899:2011] | Subclause 6.2.4, "Storage Durations of Objects" |
...