]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
fix memory leak in router.c; start relying on NULL==(zero bytes)
authorNick Mathewson <nickm@torproject.org>
Sat, 16 Oct 2004 20:38:57 +0000 (20:38 +0000)
committerNick Mathewson <nickm@torproject.org>
Sat, 16 Oct 2004 20:38:57 +0000 (20:38 +0000)
svn:r2538

src/common/crypto.c
src/or/config.c
src/or/dns.c
src/or/onion.c
src/or/router.c
src/or/routerparse.c

index 782651205819fa82faade8ecf5379b0327d90e62..651822254cdedbe46c269d00a4837fae0bcf43c2 100644 (file)
@@ -1200,8 +1200,7 @@ crypto_dh_env_t *crypto_dh_new()
   if (!dh_param_p)
     init_dh_param();
 
-  res = tor_malloc(sizeof(crypto_dh_env_t));
-  res->dh = NULL;
+  res = tor_malloc_zero(sizeof(crypto_dh_env_t));
 
   if (!(res->dh = DH_new()))
     goto err;
index fe386d8df1be55b11d1c198de22514af98d6ca1c..41ccd56bd35d1a88a38a7953e4fdd095ff224a42 100644 (file)
@@ -492,22 +492,13 @@ static void
 init_options(or_options_t *options)
 {
   memset(options,0,sizeof(or_options_t));
-  options->LogOptions = NULL;
   options->ExitNodes = tor_strdup("");
   options->EntryNodes = tor_strdup("");
   options->StrictEntryNodes = options->StrictExitNodes = 0;
   options->ExcludeNodes = tor_strdup("");
   options->RendNodes = tor_strdup("");
   options->RendExcludeNodes = tor_strdup("");
-  options->ExitPolicy = NULL;
-  options->SocksPolicy = NULL;
-  options->SocksBindAddress = NULL;
-  options->ORBindAddress = NULL;
-  options->DirBindAddress = NULL;
-  options->OutboundBindAddress = NULL;
-  options->RecommendedVersions = NULL;
-  options->PidFile = NULL; // tor_strdup("tor.pid");
-  options->DataDirectory = NULL;
+  /* options->PidFile = tor_strdup("tor.pid"); */
   options->PathlenCoinWeight = 0.3;
   options->MaxConn = 900;
   options->DirFetchPostPeriod = 600;
@@ -517,11 +508,6 @@ init_options(or_options_t *options)
   options->BandwidthRate = 800000; /* at most 800kB/s total sustained incoming */
   options->BandwidthBurst = 10000000; /* max burst on the token bucket */
   options->NumCpus = 1;
-  options->RendConfigLines = NULL;
-  options->FirewallPorts = NULL;
-  options->DirServers = NULL;
-  options->MyFamily = NULL;
-  options->NodeFamilies = NULL;
 }
 
 static char *
index c4d4a363a58ca44a61da8e83847d7807bee72dfa..56f7378982ffc435529c936c8d09c0df87b5b0ea 100644 (file)
@@ -243,7 +243,6 @@ int dns_resolve(connection_t *exitconn) {
   /* add us to the pending list */
   pending_connection = tor_malloc_zero(sizeof(struct pending_connection_t));
   pending_connection->conn = exitconn;
-  pending_connection->next = NULL;
   resolve->pending_connections = pending_connection;
   exitconn->state = EXIT_CONN_STATE_RESOLVING;
 
index 0a1c2645270ae106d0ea6f003e74667ccda23d30..ada1749bf5c5c3077a11b6e93589d99ae48b599b 100644 (file)
@@ -29,9 +29,8 @@ static int ol_length=0;
 int onion_pending_add(circuit_t *circ) {
   struct onion_queue_t *tmp;
 
-  tmp = tor_malloc(sizeof(struct onion_queue_t));
+  tmp = tor_malloc_zero(sizeof(struct onion_queue_t));
   tmp->circ = circ;
-  tmp->next = NULL;
 
   if(!ol_tail) {
     tor_assert(!ol_list);
index ab606ee69b22ba4e75076724a6e28ec70db9cf00..26a4b97f6d600d6b628bf92b7d106a4980737a27 100644 (file)
@@ -547,7 +547,6 @@ int router_rebuild_descriptor(void) {
   ri->bandwidthrate = options.BandwidthRate;
   ri->bandwidthburst = options.BandwidthBurst;
   ri->bandwidthcapacity = router_get_bandwidth_capacity();
-  ri->exit_policy = NULL; /* zero it out first */
   router_add_exit_policy_from_config(ri);
   ri->is_trusted_dir = authdir_mode();
   if(desc_routerinfo) /* inherit values */
@@ -556,8 +555,6 @@ int router_rebuild_descriptor(void) {
     ri->declared_family = smartlist_create();
     smartlist_split_string(ri->declared_family, options.MyFamily, ",",
                            SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
-  } else {
-    ri->declared_family = NULL;
   }
 
   if (desc_routerinfo)
@@ -684,7 +681,7 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
     (int) router->bandwidthcapacity,
     onion_pkey, identity_pkey,
     family_line, bandwidth_usage);
-
+  tor_free(family_line);
   tor_free(onion_pkey);
   tor_free(identity_pkey);
   tor_free(bandwidth_usage);
index 540e8b338e1a6a80709934c40e2be10d14d064d8..dd858f8fafbebbc537b9075178267667a25fee90 100644 (file)
@@ -718,9 +718,8 @@ router_parse_list_from_string(const char **s, routerlist_t **dest,
 
   if (*dest)
     routerlist_free(*dest);
-  *dest = tor_malloc(sizeof(routerlist_t));
+  *dest = tor_malloc_zero(sizeof(routerlist_t));
   (*dest)->routers = routers;
-  (*dest)->software_versions = NULL;
 
   return 0;
 }
@@ -770,8 +769,6 @@ routerinfo_t *router_parse_entry_from_string(const char *s,
   }
 
   router = tor_malloc_zero(sizeof(routerinfo_t));
-  router->onion_pkey = router->identity_pkey = NULL;
-  router->declared_family = NULL;
   ports_set = bw_set = 0;
 
   if (tok->n_args == 2 || tok->n_args == 5 || tok->n_args == 6) {
@@ -1122,7 +1119,6 @@ router_parse_exit_policy(directory_token_t *tok) {
          address, inet_ntoa(in), newe->prt_min, newe->prt_max);
   tor_free(address);
 
-  newe->next = NULL;
   return newe;
 
 policy_read_failed: