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 - WRITE_UNINIT_PTR



WRITE_UNINIT_PTR

Writing to an uninitialized pointer

This error is generated whenever an uninitialized pointer is dereferenced.

Problem

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

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

Diagnosis (at runtime)

	[writuptr.c:8] **WRITE_UNINIT_PTR**
1.	>> 		*a = 123;
	
2.		Writing to an uninitialized pointer: a

		Stack trace where the error occurred:
3.				main() writuptr.c, 8
	
4.		**Memory corrupted. Program may crash!!**
  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.
  4. Informational message indicating that a serious error has occurred which may cause the program to 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;
        }

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