Browse code

Better use of destroy mode

git-svn: trunk@2059

Nigel Horne authored on 2006/07/02 06:04:47
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Jul  1 22:04:04 BST 2006 (njh)
2
+----------------------------------
3
+  * libclamav:	More freeing memory earlier
4
+
1 5
 Sat Jul  1 17:18:17 BST 2006 (njh)
2 6
 ----------------------------------
3 7
   * libclamav:	Free memory earlier
... ...
@@ -16,7 +16,7 @@
16 16
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
  *  MA 02110-1301, USA.
18 18
  */
19
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.314 2006/07/01 16:17:35 njh Exp $";
19
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.315 2006/07/01 21:03:36 njh Exp $";
20 20
 
21 21
 #if HAVE_CONFIG_H
22 22
 #include "clamav-config.h"
... ...
@@ -2862,8 +2862,8 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx)
2862 2862
 			if(t && ((fb = fileblobCreate()) != NULL)) {
2863 2863
 				cli_dbgmsg("Found a bounce message\n");
2864 2864
 				fileblobSetFilename(fb, mctx->dir, "bounce");
2865
-				/*fileblobSetCTX(fb, ctx);*/
2866
-				if(textToFileblob(start, fb, 0) == NULL)
2865
+				/*fileblobSetCTX(fb, mctx->ctx);*/
2866
+				if(textToFileblob(start, fb, 1) == NULL)
2867 2867
 					cli_dbgmsg("Nothing new to save in the bounce message\n");
2868 2868
 				else
2869 2869
 					rc = 1;
... ...
@@ -2898,7 +2898,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx)
2898 2898
 						28);
2899 2899
 
2900 2900
 					/*fileblobSetCTX(fb, ctx);*/
2901
-					fb = textToFileblob(t_line, fb, 0);
2901
+					fb = textToFileblob(t_line, fb, 1);
2902 2902
 
2903 2903
 					fileblobDestroy(fb);
2904 2904
 				}
... ...
@@ -2913,9 +2913,6 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx)
2913 2913
 
2914 2914
 			if(saveIt) {
2915 2915
 				cli_dbgmsg("Saving text part to scan\n");
2916
-				/*
2917
-				 * TODO: May be better to save aText
2918
-				 */
2919 2916
 				saveTextPart(mainMessage, mctx->dir);
2920 2917
 				if(mainMessage != messageIn) {
2921 2918
 					messageDestroy(mainMessage);
... ...
@@ -17,6 +17,9 @@
17 17
  *  MA 02110-1301, USA.
18 18
  *
19 19
  * $Log: text.c,v $
20
+ * Revision 1.22  2006/07/01 21:03:36  njh
21
+ * Better use of destroy mode
22
+ *
20 23
  * Revision 1.21  2006/07/01 16:17:35  njh
21 24
  * Added destroy flag
22 25
  *
... ...
@@ -73,7 +76,7 @@
73 73
  *
74 74
  */
75 75
 
76
-static	char	const	rcsid[] = "$Id: text.c,v 1.21 2006/07/01 16:17:35 njh Exp $";
76
+static	char	const	rcsid[] = "$Id: text.c,v 1.22 2006/07/01 21:03:36 njh Exp $";
77 77
 
78 78
 #if HAVE_CONFIG_H
79 79
 #include "clamav-config.h"
... ...
@@ -284,6 +287,11 @@ textToBlob(text *t, blob *b, int destroy)
284 284
 
285 285
 	(void)textIterate(t, addToBlob, b, destroy);
286 286
 
287
+	if(destroy && t->t_next) {
288
+		textDestroy(t->t_next);
289
+		t->t_next = NULL;
290
+	}
291
+
287 292
 	blobClose(b);
288 293
 
289 294
 	return b;
... ...
@@ -303,7 +311,12 @@ textToFileblob(text *t, fileblob *fb, int destroy)
303 303
 	} else
304 304
 		fb->ctx = NULL;	/* no need to scan */
305 305
 
306
-	return textIterate(t, addToFileblob, fb, destroy);
306
+	fb = textIterate(t, addToFileblob, fb, destroy);
307
+	if(destroy && t->t_next) {
308
+		textDestroy(t->t_next);
309
+		t->t_next = NULL;
310
+	}
311
+	return fb;
307 312
 }
308 313
 
309 314
 static void