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

[or-cvs] Fix a memory leak in smartlist_string_remove.



Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv4657/src/common

Modified Files:
	container.c 
Log Message:
Fix a memory leak in smartlist_string_remove.

Index: container.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- container.c	9 Sep 2005 23:12:54 -0000	1.34
+++ container.c	12 Sep 2005 05:20:29 -0000	1.35
@@ -121,7 +121,7 @@
     }
 }
 
-/** If there are any strings in sl equal to element, remove them.
+/** If there are any strings in sl equal to element, remove and free them.
  * Does not preserve order. */
 void
 smartlist_string_remove(smartlist_t *sl, const char *element)
@@ -131,6 +131,7 @@
   tor_assert(element);
   for (i = 0; i < sl->num_used; ++i) {
     if (!strcmp(element, sl->list[i])) {
+      tor_free(sl->list[i]);
       sl->list[i] = sl->list[--sl->num_used]; /* swap with the end */
       i--; /* so we process the new i'th element */
     }