summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-16 20:38:57 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-16 20:38:57 +0000
commita42adce3628c9b82c91ff21e85c6a2d4fbcefc13 (patch)
treeb7f04f7a405e5638f21ad1fd86d77e216e517d75
parentb0afd91afec362e3edc58d1928d2a63bcb3097e8 (diff)
downloadtor-a42adce3628c9b82c91ff21e85c6a2d4fbcefc13.tar.gz
tor-a42adce3628c9b82c91ff21e85c6a2d4fbcefc13.zip
fix memory leak in router.c; start relying on NULL==(zero bytes)
svn:r2538
-rw-r--r--src/common/crypto.c3
-rw-r--r--src/or/config.c16
-rw-r--r--src/or/dns.c1
-rw-r--r--src/or/onion.c3
-rw-r--r--src/or/router.c5
-rw-r--r--src/or/routerparse.c6
6 files changed, 5 insertions, 29 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 7826512058..651822254c 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -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;
diff --git a/src/or/config.c b/src/or/config.c
index fe386d8df1..41ccd56bd3 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -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 *
diff --git a/src/or/dns.c b/src/or/dns.c
index c4d4a363a5..56f7378982 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -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;
diff --git a/src/or/onion.c b/src/or/onion.c
index 0a1c264527..ada1749bf5 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -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);
diff --git a/src/or/router.c b/src/or/router.c
index ab606ee69b..26a4b97f6d 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -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);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 540e8b338e..dd858f8faf 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -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: