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



FREE_LOCAL

Freeing local memory

This error is generated if the address of a local variable is passed to free.

Problem

The following code attempts to free a local variable that was not dynamically allocated.


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

Diagnosis (at runtime)


	[freelocl.c:9] **FREE_LOCAL**
1.	>> 		free(a);
	
2.		Freeing local memory: a
	
3.		Pointer	   : 0xf7fffb0f
		In block   : 0xf7fffb0f thru 0xf7fffb0f (1 byte)
4.			     b,declared at freelocl.c, 6

		Stack trace where the error occurred:
5.			     main() freelocl.c, 9
	
6.		**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. Value of the pointer that is being deallocated.
  4. Information about the block of memory addressed by this pointer, including information about where this block was declared.
  5. Stack trace showing the function call sequence leading to the error.
  6. Informational message indicating that a serious error has occurred which may cause the program to crash.

Repair

Some systems allow this operation since they keep track of which blocks of memory are actually dynamically allocated, but this is not portable programming practice and is not recommended.

In most cases, this error will result from a simple coding mistake at the indicated source line which can be quickly corrected.

If your application is unable to distinguish between local variables and dynamically allocated memory blocks, you can suppress error messages by adding the option

	insure++.suppress FREE_LOCAL

to the .psrc file.


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