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

[or-cvs] r10905: Fix/note some relatively trivial mem usage issues (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2007-07-22 18:49:49 -0400 (Sun, 22 Jul 2007)
New Revision: 10905

Modified:
   tor/trunk/
   tor/trunk/src/common/torgzip.c
   tor/trunk/src/or/circuitbuild.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/routerlist.c
Log:
 r13858@catbus:  nickm | 2007-07-22 18:44:02 -0400
 Fix/note some relatively trivial mem usage issues



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13858] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/torgzip.c
===================================================================
--- tor/trunk/src/common/torgzip.c	2007-07-22 22:36:46 UTC (rev 10904)
+++ tor/trunk/src/common/torgzip.c	2007-07-22 22:49:49 UTC (rev 10905)
@@ -136,6 +136,10 @@
   }
  done:
   *out_len = stream->total_out;
+  if (stream->total_out > out_size + 4097) {
+    /* If we're wasting more than 4k, don't. */
+    tor_realloc(*out, stream->total_out + 1);
+  }
   if (deflateEnd(stream)!=Z_OK) {
     log_warn(LD_BUG, "Error freeing gzip structures");
     goto err;

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2007-07-22 22:36:46 UTC (rev 10904)
+++ tor/trunk/src/or/circuitbuild.c	2007-07-22 22:49:49 UTC (rev 10905)
@@ -1072,7 +1072,8 @@
   int i;
 
   for (i = 0; i < smartlist_len(source); ++i) {
-    tmp = tor_malloc(sizeof(uint16_t));
+    /*XXXX020 some of these are leaked somewhere.. fix that. */
+    tmp = tor_malloc(sizeof(uint16_t)); 
     memcpy(tmp, smartlist_get(source, i), sizeof(uint16_t));
     smartlist_add(dest, tmp);
   }

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-07-22 22:36:46 UTC (rev 10904)
+++ tor/trunk/src/or/main.c	2007-07-22 22:49:49 UTC (rev 10905)
@@ -1763,6 +1763,7 @@
   routerlist_free_all();
   addressmap_free_all();
   set_exit_redirects(NULL); /* free the registered exit redirects */
+  esc_router_info(NULL); /* free a static field */
   dirserv_free_all();
   rend_service_free_all();
   rend_cache_free_all();

Modified: tor/trunk/src/or/routerlist.c
===================================================================