title: c++ new/delete and char *
body: <p>Can anyone help me, why I'm getting an error message while trying to free the allocated memory: Heap corruption detected. CTR detected the application wrote the memory after end of heap buffer. </p>
  
  <pre><code>char *ff (char *s){
      char *s1 = new char [strlen(s)];
      strcpy(s1, s);
      return s1;
  }
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      char *s = new char [5];
  
      strcpy(s, "hello");
      char *s2 = ff(s);
  
      delete []s;     // This works normal
      delete []s2;    // But I get an error on that line
      return 0;
  }
  </code></pre>