fix memory leaks and cleanup clamav_plugin.c
authorPaul Mangan <paul@claws-mail.org>
Sun, 13 Apr 2003 13:00:43 +0000 (13:00 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sun, 13 Apr 2003 13:00:43 +0000 (13:00 +0000)
ChangeLog.claws
configure.ac
src/plugins/clamav/clamav_plugin.c

index b391338..155942c 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-13 [paul]      0.8.11claws88
+
+       * src/plugins/clamav/clamav_plugin.c
+               fix memory leaks
+               clean up
+
 2003-04-12 [paul]      0.8.11claws87
 
        * src/plugins/clamav/clamav_plugin.c
index a3de32d..bea699c 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws87
+EXTRA_VERSION=claws88
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 0d729b8..e995f15 100644 (file)
 #include "defs.h"
 
 #include <glib.h>
-
-#if HAVE_LOCALE_H
-#  include <locale.h>
-#endif
-
 #include <clamav.h>
 
 #include "common/plugin.h"
@@ -148,45 +143,48 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                        g_warning("Can't get the part of multipart message.");
                else {
                        debug_print("Scanning %s\n", outfile);
-                       if((ret = cl_scanfile(outfile, &virname, &size, root, 
+                       if ((ret = cl_scanfile(outfile, &virname, &size, root, 
                                              &limits, scan_archive)) == CL_VIRUS) {
                                is_infected = TRUE;
                                debug_print("Detected %s virus.\n", virname); 
                        } else {
                                debug_print("No virus detected.\n");
-                               if(ret != CL_CLEAN)
+                               if (ret != CL_CLEAN)
                                        debug_print("Error: %s\n", cl_perror(ret));
                        }
 
                        kb = size * (CL_COUNT_PRECISION / 1024);
                        debug_print("Data scanned: %2.2Lf Kb\n", kb);
     
-                       if (is_infected) {
-                               debug_print("message part(s) infected with %s\n", virname);
-                               if (config.clamav_receive_infected) {
-                                       FolderItem *clamav_save_folder;
-
-                                       if ((!config.clamav_save_folder) ||
-                                       (config.clamav_save_folder[0] == '\0') ||
-                                       ((clamav_save_folder = folder_find_item_from_identifier(config.clamav_save_folder)) == NULL))
-                                               clamav_save_folder = folder_get_default_trash();
-
-                                       procmsg_msginfo_unset_flags(msginfo, ~0, 0);
-                                       folder_item_move_msg(clamav_save_folder, msginfo);
-                               } else {
-                                       folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
-                               }
-
-                               return TRUE;
-                       }
-                               child = child->next;
+                       unlink(outfile);
+
+                       if (is_infected) break;
+                       child = child->next;
+               }
+       }
+
+       if (is_infected) {
+               debug_print("message part(s) infected with %s\n", virname);
+               if (config.clamav_receive_infected) {
+                       FolderItem *clamav_save_folder;
+
+                       if ((!config.clamav_save_folder) ||
+                           (config.clamav_save_folder[0] == '\0') ||
+                           ((clamav_save_folder = folder_find_item_from_identifier(config.clamav_save_folder)) == NULL))
+                                   clamav_save_folder = folder_get_default_trash();
+
+                       procmsg_msginfo_unset_flags(msginfo, ~0, 0);
+                       folder_item_move_msg(clamav_save_folder, msginfo);
+               } else {
+                       folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
                }
        }
+       
        cl_freetrie(root);
        g_free(infile);
        procmime_mimeinfo_free_all(mimeinfo);
-
-       return FALSE;
+       
+       return is_infected;
 }
 
 #undef IS_FIRST_PART_TEXT