[tor-bugs] #4251 [Tor Hidden Services]: memory leak for hidden service?

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Wed Nov 9 01:35:29 UTC 2011


#4251: memory leak for hidden service?
------------------------------------+---------------------------------------
    Reporter:  arma                 |       Owner:  rransom           
        Type:  defect               |      Status:  closed            
    Priority:  normal               |   Milestone:  Tor: 0.2.2.x-final
   Component:  Tor Hidden Services  |     Version:                    
  Resolution:  fixed                |    Keywords:                    
      Parent:                       |      Points:                    
Actualpoints:                       |  
------------------------------------+---------------------------------------

Comment(by rransom):

 Replying to [comment:6 nickm]:
 > subtle!  I'll merge it.  One question: what is up with the
 > {{{
 >    foo *p = thing->the_foo;
 >    thing->the_foo = NULL;
 >    foo_free(p);
 > }}}
 > pattern?  Why not just
 > {{{
 >    foo_free(thing->the_foo);
 >    thing->the_foo = NULL;
 > }}}
 > ?
 >
 > It doesn't look bad to me, but I want to understand the point of it.

 It's a (bad) habit I picked up from programming in Delphi 5, to make the
 free-and-set-to-NULL process look almost thread-safe.  (It's not thread-
 safe if other threads can ever write the variable.)  I'll try to resist
 that temptation in the future, because there really is no point.

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


More information about the tor-bugs mailing list