]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix a rare memleak during stats writing
authorSebastian Hahn <sebastian@torproject.org>
Wed, 8 Jun 2011 19:35:26 +0000 (21:35 +0200)
committerSebastian Hahn <sebastian@torproject.org>
Wed, 8 Jun 2011 19:35:26 +0000 (21:35 +0200)
If rep_hist_buffer_stats_write() was called unitinitalized, we'd leak
memory.

changes/coverity_maint
src/or/rephist.c

index 6d60355b113411ae76484ff5b020843057a1e115..e7be90a4852925a9a2e1ae72f62f6b7289aa0f84 100644 (file)
@@ -5,4 +5,5 @@
     - Add some forgotten return value checks during unit tests. Found
       by coverity.
     - Don't use 1-bit wide signed bit fields. Found by coverity.
+    - Fix a rare memory leak during stats writing. Found by coverity.
 
index 242fe81d52227cc58e26558ce79cf9d2ae453c80..54593a06c3470cf25898eb2196e4fb488b1eff31 100644 (file)
@@ -2451,8 +2451,8 @@ rep_hist_buffer_stats_write(time_t now)
   int processed_cells[SHARES], circs_in_share[SHARES],
       number_of_circuits, i;
   double queued_cells[SHARES], time_in_queue[SHARES];
-  smartlist_t *str_build = smartlist_create();
-  char *str = NULL, *buf=NULL;
+  smartlist_t *str_build = NULL;
+  char *str = NULL, *buf = NULL;
   circuit_t *circ;
 
   if (!start_of_buffer_stats_interval)
@@ -2460,6 +2460,8 @@ rep_hist_buffer_stats_write(time_t now)
   if (start_of_buffer_stats_interval + WRITE_STATS_INTERVAL > now)
     goto done; /* Not ready to write */
 
+  str_build = smartlist_create();
+
   /* add current circuits to stats */
   for (circ = _circuit_get_global_list(); circ; circ = circ->next)
     rep_hist_buffer_stats_add_circ(circ, now);