Insure++ Reference - FREE_DANGLING
This error is generated when a memory block is freed multiple times.
The following code frees the same pointer twice.
1: /*
2: * File: freedngl.c
3: */
4: #include <stdlib.h>
5:
6: main()
7: {
8: char *a = (char *)malloc(10);
9: free(a);
10: free(a);
11: return (0);
12: }
[freedngl.c:10] **FREE_DANGLING**
1. >> free(a);
2. Freeing dangling pointer: a
3. Pointer : 0x000173e0
In block : 0x000173e0 thru 0x000173e9 (10 bytes)
block allocated at:
4. malloc() (interface)
main() freedngl.c, 8
5. stack trace where memory was freed:
main() freedngl.c, 9
6. Stack trace where the error occurred:
main() freedngl.c, 10
7. **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 allocated.
- Stack trace showing where this block was freed.
- 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 memory blocks to be freed multiple times. However,
this is not portable and is not a recommended practice.
The information supplied in the diagnostics will allow you to see the
line of code which previously de-allocated this block of memory. You
should attempt to remove one of the two calls.
If your application is unable to prevent multiple calls to deallocate
the same block, you can suppress error messages by adding the option
insure++.suppress FREE_DANGLING
to the .psrc file.
FREE_BODY
FREE_GLOBAL
|