title: Does free(ptr) where ptr is NULL corrupt memory?
body: <p>Theoretically I can say that </p>
  
  <pre><code>free(ptr);
  free(ptr); 
  </code></pre>
  
  <p>is a memory corruption since we are freeing the memory which has already been freed.</p>
  
  <p>But what if </p>
  
  <pre><code>free(ptr);
  ptr=NULL;
  free(ptr); 
  </code></pre>
  
  <p>As the OS will behave in an undefined manner I cannot get an actual theoretical analysis for this about what's happening.
  Whatever I am doing, is this memory corruption or not?</p>
  
  <p>Is freeing a NULL pointer valid?</p>