In this section:
Overview
This error is generated when an attempt is made to de-allocate memory by using a pointer which currently points into the middle of a block, rather than to its beginning. Freeing memory block from bodyCode Description Enabled Reported Platform FREE_BODY Runtime Windows/Unix
Problem
The following code attempts to free a memory region using an invalid pointer.
/* * File: freebody.c */ #include <stdlib.h> main() { char *a = (char *)malloc(10); free(a+1); }
Diagnosis at Runtime
[freebody.c:9] **FREE_BODY** >> free(a+1); Freeing memory block from body: a + 1 Pointer : 0x000173e9 Stack trace where the error occurred: main() freebody.c, 9 **Memory corrupted. Program may crash!!**
- Line 2: Source line at which the problem was detected.
- Line 3: Description of the problem and the expression that is in error.
- Line 4: Value of the pointer that is being deallocated.
- Line 6: Stack trace showing the function call sequence leading to the error.
- Line 7: Informational message indicating that a serious error has occurred which may cause the program to crash.
Repair
This is normally a serious error. In most cases, the line number indicated in the diagnostics will have a simple error that can be corrected.