[tor-bugs] #24484 [Core Tor/Tor]: free(NULL) always works (nowadays) so delete comment saying that it might not

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Dec 1 20:20:35 UTC 2017


#24484: free(NULL) always works (nowadays) so delete comment saying that it might
not
------------------------------+--------------------------------
     Reporter:  catalyst      |      Owner:  (none)
         Type:  defect        |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: 0.3.3.x-final
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:  easy
Actual Points:                |  Parent ID:
       Points:                |   Reviewer:
      Sponsor:                |
------------------------------+--------------------------------
 src/common/util.h has the following text in a comment:
 {{{
  * Unlike the free() function, tor_free() will still work on NULL
 pointers,
  * and it sets the pointer value to NULL after freeing it.
 }}}

 `free(NULL)` has been required to be a no-op since C89 at least.  Some
 pre-ANSI platforms might have had a libc `free()` that didn't allow a null
 pointer, but we mostly don't care about those.

 We should stop propagating this common misconception that `free(NULL)`
 might undefined on modern platforms.  We should remove that text from the
 comment and remove the conditional from the implementation.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24484>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list