In this section:
This error is generated whenever an attempt is made to de-allocate memory by means of an uninitialized pointer.
|
This code attempts to free a pointer which has not been initialized.
/* * File: freeuptr.c */ main() { char *a; free(a); return (0); } |
[freeuptr.c:7] **FREE_UNINIT_PTR** >> free(a); Freeing uninitialized pointer: a Stack trace where the error occurred: main() freeuptr.c, 7 **Memory corrupted. Program may crash!!** |
Some systems appear to allow this operation, since they will refuse to free memory that was not dynamically allocated. Relying on this behavior is very dangerous, however, since an uninitialized pointer may “accidentally” point to a block of memory that was dynamically allocated, but should not be freed.