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

[or-cvs] Fix segfault and memleak when getting many compressed serve...



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

Modified Files:
	directory.c 
Log Message:
Fix segfault and memleak when getting many compressed server descs.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -d -r1.267 -r1.268
--- directory.c	8 Sep 2005 21:46:31 -0000	1.267
+++ directory.c	8 Sep 2005 22:00:29 -0000	1.268
@@ -1222,16 +1222,17 @@
         /* XXXX NM This could be way more efficiently handled. */
         if (tor_gzip_compress(&compressed, &compressed_len,
                               inp, cp-inp, ZLIB_METHOD)<0) {
-          tor_free(cp);
+          tor_free(inp);
           smartlist_free(descs);
           return -1;
         }
-        tor_free(cp);
+        tor_free(inp);
         tor_snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Length: %d\r\nContent-Type: application/octet-stream\r\n\r\n",
                      date,
                      (int)compressed_len);
         connection_write_to_buf(tmp, strlen(tmp), conn);
         connection_write_to_buf(compressed, compressed_len, conn);
+        tor_free(compressed);
       } else {
         tor_snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nDate: %s\r\nContent-Length: %d\r\nContent-Type: application/octet-stream\r\n\r\n",
                      date,