In this section:

Overview

This error is generated whenever an uninitialized pointer is dereferenced.

CodeDescriptionEnabledReportedPlatform
WRITE_UNINIT_PTRWriting to an uninitialized pointer(tick)RuntimeWindows/Unix


Problem

The following code attempts to use the value of the pointer a, even though it has not been initialized.

/*
 * File: writuptr.c
 */
main()
{
	int *a;

	*a = 123;
	return (0);
}

Diagnosis at Runtime

[writuptr.c:8] **WRITE_UNINIT_PTR**
>>		*a = 123;
Writing to an uninitialized pointer: 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() writuptr.c, 8
**Memory corrupted. Program may crash!!**

Repair

This problem is usually caused by omitting an assignment or allocation statement that would initialize a pointer. The code given, for example, could be corrected by including an assignment as shown below.

/*
* File: writuptr.c (Modified)
*/
main()
{
	int *a, b;
	a = &b;
	*a = 123;
}

References

The table below shows Common Weakness Enumerations associated with this error.

CWEDescription
CWE-457Use of uninitialized variable
CWE-824Access of uninitialized pointer
CWE-908Use of uninitialized resource