[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] fix memory leak in router.c; start relying on NULL==(zero b...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] fix memory leak in router.c; start relying on NULL==(zero b...
- From: nickm@seul.org (Nick Mathewson)
- Date: Sat, 16 Oct 2004 16:38:59 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sat, 16 Oct 2004 16:39:26 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv16599/src/or
Modified Files:
config.c dns.c onion.c router.c routerparse.c
Log Message:
fix memory leak in router.c; start relying on NULL==(zero bytes)
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- config.c 15 Oct 2004 20:52:09 -0000 1.173
+++ config.c 16 Oct 2004 20:38:56 -0000 1.174
@@ -492,22 +492,13 @@
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 @@
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: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- dns.c 14 Oct 2004 02:47:08 -0000 1.111
+++ dns.c 16 Oct 2004 20:38:56 -0000 1.112
@@ -243,7 +243,6 @@
/* 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: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- onion.c 14 Oct 2004 02:47:09 -0000 1.165
+++ onion.c 16 Oct 2004 20:38:57 -0000 1.166
@@ -29,9 +29,8 @@
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: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- router.c 15 Oct 2004 01:58:11 -0000 1.98
+++ router.c 16 Oct 2004 20:38:57 -0000 1.99
@@ -547,7 +547,6 @@
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 @@
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->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: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- routerparse.c 15 Oct 2004 01:58:11 -0000 1.57
+++ routerparse.c 16 Oct 2004 20:38:57 -0000 1.58
@@ -718,9 +718,8 @@
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 @@
}
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 @@
address, inet_ntoa(in), newe->prt_min, newe->prt_max);
tor_free(address);
- newe->next = NULL;
return newe;
policy_read_failed: