[or-cvs] r10902: free a small static string on exit. (tor/trunk/src/or)

arma at seul.org arma at seul.org
Sun Jul 22 06:32:28 UTC 2007


Author: arma
Date: 2007-07-22 02:32:28 -0400 (Sun, 22 Jul 2007)
New Revision: 10902

Modified:
   tor/trunk/src/or/main.c
   tor/trunk/src/or/routerlist.c
Log:
free a small static string on exit.


Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-07-22 04:36:33 UTC (rev 10901)
+++ tor/trunk/src/or/main.c	2007-07-22 06:32:28 UTC (rev 10902)
@@ -1784,6 +1784,7 @@
   tor_free(timeout_event);
   /* Stuff in util.c */
   escaped(NULL);
+  esc_router_info(NULL);
   if (!postfork) {
     logs_free_all(); /* free log strings. do this last so logs keep working. */
   }

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-07-22 04:36:33 UTC (rev 10901)
+++ tor/trunk/src/or/routerlist.c	2007-07-22 06:32:28 UTC (rev 10902)
@@ -5391,15 +5391,19 @@
  * THIS FUNCTION IS NOT REENTRANT.  Don't call it from outside the main
  * thread.  Also, each call invalidates the last-returned value, so don't
  * try log_warn(LD_GENERAL, "%s %s", esc_router_info(a), esc_router_info(b));
+ *
+ * If <b>router</b> is NULL, it just frees its internal memory and returns.
  */
 const char *
 esc_router_info(routerinfo_t *router)
 {
-  static char *info;
+  static char *info=NULL;
   char *esc_contact, *esc_platform;
   size_t len;
   if (info)
     tor_free(info);
+  if (!router)
+    return NULL; /* we're exiting; just free the memory we use */
 
   esc_contact = esc_for_log(router->contact_info);
   esc_platform = esc_for_log(router->platform);



More information about the tor-commits mailing list