#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<mcheck.h>

void myleak();

int main()
{
  int i;

  mtrace();

  myleak();

  return 0;
}

void myleak()
{
  char str1[] = "string 1";
  char str2[] = "string 2";
  char * str3;

  str3  = (char *)malloc((strlen(str1)+1) * sizeof(char));

  strcpy(str3, str1);

  str3 = (char *) malloc((strlen(str2)+1)  * sizeof(char));

  strcpy(str3, str1);

  char * tmp = str3;
  free(str3);

  if(tmp == str3)
    printf("Value of str3 is unchanged\n\n");
  else
    printf("Value of str3 is modified\n\n");

  str3 = NULL;

  return;
}
