Search

ParaSoft

HOME
PRODUCTS
SUPPORT
ABOUT
WHAT'S NEW
EVENTS


Insure++

Quick facts

Add-on Modules:
   -INUSE
   -TCA

Comparisons

Technical Papers

Support & Manuals

FAQs

Recent Reviews

User Testimonials

Press Releases


Insure tool to debug c++





Insure++ Reference - READ_UNINIT_PTR



READ_UNINIT_PTR

Reading from uninitialized pointer

This error is generated whenever an uninitialized pointer is dereferenced.

Bend

This error category will be disabled if full uninitialized memory checking is in effect (the default). In this case, errors are detected in the READ_UNINIT_MEM category instead.

Problem

This code attempts to use the value of the pointer a, even though it has never been initialized.

	1:	/*
	2:	 * File: readuptr.c
	3:	 */
	4:	main()
	5:	{
	6:		int b, *a;
	7:
	8:		b = *a; bug
	9:		return (0);
	10:	}

Diagnosis (at runtime)

	[readuptr.c:8] **READ_UNINIT_PTR**
1.	>> 		b = *a;
	
2.		Reading uninitialized pointer: a

		Stack trace where the error occurred:
3.				main() readuptr.c, 8

  1. Source line at which the problem was detected.
  2. Description of the problem and the expression that is in error.
  3. Stack trace showing the function call sequence leading to the error.

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: readuptr.c (Modified)
 	 */
	main()
	{
  	     int b, *a, c;

  	     a = &c;
             b = *a;
	     return (0);
	}

< READ_UNINIT_MEM > READ_WILD
Tools to debug c++ and java
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft