title: Heap memory corruption
body: <pre><code>int main()
  {
      char *p = new char[100];
      strcpy(p, "Test");
      cout &lt;&lt; "Before heap corruption: " &lt;&lt; p &lt;&lt; endl;
      p[150] = '\0';
  
      cout &lt;&lt; "after heap corruption: " &lt;&lt; p;
  
      delete p;
  
      getchar();
      return 0;
  }
  </code></pre>
  
  <p>In the above mentioned code above, I am writing '\0' at a memory location which is not mine, even then no exception is thrown. 
  If the above code is run with commenting delete p, no exeception will be thrown. But if it is uncommented, the attached exception is thrown. So, it is <strong><em>delete</em></strong> that validates the memory ownership. So, may I know how eaxctly delete works and why there is nosuch validation while writing out of memory block</p>
  
  <p><img src="https://i.stack.imgur.com/GyMom.png" alt="enter image description here"></p>