In this section:
This error is generated whenever an expression operates on an uninitialized pointer.
|
In the following code uses an uninitialized pointer.
/* * File: expuptr.c */ main() { char *a, b[10], c[10]; if (a > b) a = b; return (0); } |
[expuptr.c:8] **EXPR_UNINIT_PTR** >> if (a > b) Expression uses uninitialized pointer: a > b ---- Associated Common Weakness Enumerations ---- CWE-457: Use of uninitialized variable CWE-824: Access of uninitialized pointer CWE-908: Use of uninitialized resource Stack trace where the error occurred: main() expuptr.c, 8 |
This error is normally caused by omitting an assignment statement for the uninitialized variable. The example code can be corrected as follows:
/* * File: expuptr.c (modified) */ main() { char *a, b[10], c[10]; a = c; if (a > b) a = b; return (0); } |
The table below shows Common Weakness Enumerations associated with this error.
CWE | Description |
---|---|
CWE-457 | Use of uninitialized variable |
CWE-824 | Access of uninitialized pointer |
CWE-908 | Use of uninitialized resource |