Listing 3 Error by Writing a Freed Pointer (Another item's value may have changed.)

#include <stdlib.h>
#include <assert.h>

void    main() {
int     *ip1;
int     *ip2;

       /* allocate an integer */
       ip1 = malloc(sizeof(int));
       assert(ip1 != NULL);
       (*ip1) = 0;

       /* deallocate the integer */
       free(ip1);

       /* allocate a second integer */
       ip2 = malloc(sizeof(int));
       assert(ip2 != NULL);
       (*ip2) = 0;
       /* note that ip1 is probably equal to ip2 */
       printf("ip1 == 0x%1x, ip2 == 0x%1x\n",ip1,ip2);

       (*ip1) = 5;
       printf("*ip2 == %d\n",*ip2);
}
/* End of File */