title: Is it necessary to check whether a pointer is null before free()
body: <p>Ì used to make sure a pointer was not null before freeing it, so I would normally destroy dynamically created structs like this:</p>
  
  <pre><code>Node *destroy_node(Node *node) {
      if (node) {
          free(node);
      }
      return NULL;
  }
  </code></pre>
  
  <p>But <a href="https://www.securecoding.cert.org/confluence/display/c/MEM34-C.+Only+free+memory+allocated+dynamically" rel="nofollow noreferrer">CERT MEM34</a> suggests that since free() accepts null pointers, I could as well write</p>
  
  <pre><code>Node *destroy_node(Node *node) {
      free(node);
      return NULL;
  }
  </code></pre>
  
  <p>Is that correct?</p>