...
Code Block | ||
---|---|---|
| ||
int func(int condition) {
int *s = NULL;
if (condition) {
s = malloc(10);
if (s == NULL) {
/* Handle Error */
}
/* insert data into s */
return 0;
}
/* ... */
if (s) {
/* This code is never reached */
}
return 0;
}
|
Compliant Solution
Remediating dead code requires the programmer to determine why the code is never executed and then resolve that situation appropriately. To correct the example above, the return
is removed from the body of the first conditional statement.
Code Block | ||
---|---|---|
| ||
int func(int condition) { int *s = NULL; if (condition) { s = malloc(10); if (s == NULL) { /* Handle Error */ } /* insert data into s */ } /* ... */ if (s) { /* This code is never reached */ } return 0; } |
Risk Assessment
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
|
|
|
|
|
|
...