[or-cvs] finally locate the memory leak,
Roger Dingledine
arma at seul.org
Fri Jan 30 20:33:07 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
routerlist.c
Log Message:
finally locate the memory leak,
plus commit a patch that doesn't fix it
(but doesn't hurt? i dunno)
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- routerlist.c 11 Jan 2004 07:41:01 -0000 1.15
+++ routerlist.c 30 Jan 2004 20:33:04 -0000 1.16
@@ -539,7 +539,7 @@
TOK_IS(K_RUNNING_ROUTERS, "running-routers");
n_good_nicknames = N_ARGS;
memcpy(good_nickname_lst, ARGS, n_good_nicknames*sizeof(char *));
- N_ARGS = 0; /* Don't free the strings in good_nickname_lst. */
+ N_ARGS = 0; /* Don't free the strings in good_nickname_lst yet. */
/* Read the router list from s, advancing s up past the end of the last
* router. */
@@ -549,6 +549,9 @@
log_fn(LOG_WARN, "Error reading routers from directory");
goto err;
}
+ for (i = 0; i < n_good_nicknames; ++i) {
+ tor_free(good_nickname_lst[i]); /* now free them */
+ }
new_dir->software_versions = versions; versions = NULL;
new_dir->published_on = published_on;
@@ -1142,6 +1145,7 @@
if (*next == '\n')
done = 1;
tok->val.cmd.args[i++] = tor_strndup(*s,next-*s);
+ /* XXX this line (the strndup) is the memory leak. */
*s = eat_whitespace_no_nl(next+1);
}
tok->val.cmd.n_args = i;
More information about the tor-commits
mailing list