In this section:
This error is generated when a call is made through an uninitialized function pointer.
|
The following code attempts to call a function through a pointer that has not been set:
/* * File: funcuptr.c */ main() { void (*a)(); a(); return (0); } |
[funcuptr.c:8] **FUNC_UNINIT_PTR** >> a(); Function pointer is uninitialized: a ---- 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() funcuptr.c, 8 **Memory corrupted. Program may crash!!** |
This problem normally occurs because some assignment statement has been omitted from the code. The current example can be fixed as follows:
extern void myfunc(); main() { void (*a)(); a = myfunc; a(); } |
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 |