In this section:

Overview

This error is generated whenever an expression operates on an uninitialized pointer.

CodeDescriptionEnabledReportedPlatform
EXPR_UNINIT_PTR

Expression uses uninitialized pointer

(tick)RuntimeWindows/Unix


Problem

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);
	}

Diagnosis at Runtime

[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

Repair

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);
	}

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