[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Fix a bug that might have caused the leak, but which might ...



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv19459

Modified Files:
	routerlist.c 
Log Message:
Fix a bug that might have caused the leak, but which might have been hiding other bugs.

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- routerlist.c	30 Jan 2004 20:38:08 -0000	1.17
+++ routerlist.c	30 Jan 2004 20:59:15 -0000	1.18
@@ -695,7 +695,7 @@
     return NULL;
   }
 
-  NEXT_TOKEN();
+  NEXT_TOKEN();  /* XXX This leaks some arguments. */
 
   if (tok->tp != K_ROUTER) {
     log_fn(LOG_WARN,"Entry does not start with \"router\"");
@@ -807,7 +807,7 @@
   NEXT_TOKEN();
   while (tok->tp == K_ACCEPT || tok->tp == K_REJECT) {
     router_add_exit_policy(router, tok);
-    NEXT_TOKEN();
+    NEXT_TOKEN(); /* This also leaks some args. XXX */
   }
 
   if (tok->tp != K_ROUTER_SIGNATURE) {
@@ -1067,11 +1067,12 @@
   char *signature = NULL;
   int i, done;
 
+  /* Clear the token _first_, so that we can clear it safely. */
+  router_release_token(tok);
+
   tok->tp = _ERR;
   tok->val.error = "";
 
-  router_release_token(tok);
-
   *s = eat_whitespace(*s);
   if (!**s) {
     tok->tp = _EOF;