In this section:
This error is generated when memory is de-allocated that is unknown to Insure++. This can occur for two reasons:
This section focuses on the first type of problem described. For information on the second type of problem, contact Parasoft's Quality Consultants.
|
The following code first assigns the pointer element of a union
type but then overwrites it with another element before finally attempting to free the initial memory block.
/* * File: freewild.c */ #include <stdlib.h> union { int *ptr; int ival; } u; main() { char *a = (char *)malloc(100); u.ptr = a; u.ival = 123; free(u.ptr); return (0); } |
[freewild.c:17] **FREE_WILD** >> free(u.ptr); Freeing wild pointer: u.ptr Pointer : 0x0000007b Stack trace where error occurred: main() freewild.c, 17 |
This problem is most conveniently tracked in a debugger by stopping the program at the indicated source line. You should then examine the illegal value and attempt to see where it was generated. Alternatively you can stop the program at some point prior to the error and single-step through the code leading up to the problem.
Wild pointers can also be generated when Insure++ does not have enough information about your program’s structure. Contact Parasoft's Quality Consultants for more information on this topic.