Insure++ Reference - FREE_LOCAL
This error is generated if the address of a local variable is passed
to free .
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);
10: return (0);
11: }
[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!!**
- Source line at which the problem was detected.
- Description of the problem and the expression that is in error.
- Value of the pointer that is being deallocated.
- Information about the block of memory addressed by this
pointer, including information about where this block
was declared.
- Stack trace showing the function call sequence leading to the
error.
- Informational message indicating that a serious error has occurred
which may cause the program to crash.
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
|