In this section:
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.
|
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); } |
[freebody.c:9] **FREE_BODY** >> free(a+1); Freeing memory block from body: a + 1 ---- Associated Common Weakness Enumerations ---- CWE-763: Release of invalid pointer or reference CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer CWE-761: Free of pointer not at start of buffer Pointer : 0x000173e9 Stack trace where the error occurred: main() freebody.c, 9 **Memory corrupted. Program may crash!!** |
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.
The table below shows Common Weakness Enumerations associated with this error.
CWE | Description |
---|---|
CWE-763 | Release of invalid pointer or reference |
CWE-119 | Improper Restriction of Operations within the Bounds of a Memory Buffer |
CWE-761 | Free of pointer not at start of buffer |