...
This example shows a function that negates an integer. If n
is a null pointer, then when n
is dereferenced the program may behave in an unexpected manner.
Code Block |
---|
void negate(int *n) {
*n = *n * -1;
}
|
...
To correct this error, ensure that n
is not a null pointer before attempting to dereference it.
Code Block |
---|
void negate(int *n) {
if(n == NULL) {
/* Handle Error */
}
*n = *n * -1;
}
|
...
Dereferencing null pointers typically results in a denial of service condition.
Component | Value |
---|---|
Severity |
|
Likelihood |
|
Remediation cost |
|
Priority |
|
Level |
|
...