Make procmsg_msginfo_free() zero out pointers to freed memory.
[claws.git] / src / partial_download.c
index 4b11c80e9c3f866417a163b65fa7c1130c6d9fad..5694b0d8e6b60701339ae4e706c848a997deca29 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Colin Leroy <colin@colino.net> 
+ * Copyright (C) 1999-2012 Colin Leroy <colin@colino.net> 
  * and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
@@ -44,6 +44,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include <glib.h>
@@ -71,7 +72,6 @@ int partial_msg_in_uidl_list(MsgInfo *msginfo)
        gchar uidl[POPBUFSIZE];
        time_t recv_time;
        time_t now;
-       gint partial_recv;
        gchar *sanitized_uid = NULL;
        
        if (!msginfo->extradata)
@@ -111,7 +111,6 @@ int partial_msg_in_uidl_list(MsgInfo *msginfo)
                gchar tmp[POPBUFSIZE];
                strretchomp(buf);
                recv_time = RECV_TIME_NONE;
-               partial_recv = POP3_TOTALLY_RECEIVED;
                
                if (sscanf(buf, "%s\t%ld\t%s", uidl, (long int *) &recv_time, 
                           tmp) < 2) {
@@ -149,7 +148,7 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
 
        filename = procmsg_get_message_file_path(msginfo);
        if (!filename) {
-               g_warning("can't get message file path.\n");
+               g_warning("can't get message file path.");
                return err;
        }
        tinfo = procheader_parse_file(filename, msginfo->flags, TRUE, TRUE);
@@ -317,8 +316,11 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
        }
 
        fclose(fp);
-       claws_unlink(filename);
-       g_rename(pathnew, filename);
+       if (rename_force(pathnew, filename) != 0) {
+               g_free(pathnew);
+               goto bail;
+       }
+
        g_free(pathnew);
        msginfo->planned_download = download;
        msgcache_update_msg(msginfo->folder->cache, msginfo);
@@ -326,7 +328,7 @@ static int partial_uidl_mark_mail(MsgInfo *msginfo, int download)
        err = 0;
 bail:
        g_free(filename);
-       procmsg_msginfo_free(tinfo);
+       procmsg_msginfo_free(&tinfo);
        
        return err;
 }
@@ -385,7 +387,6 @@ gchar *partial_get_filename(const gchar *server, const gchar *login,
        gchar uidl[POPBUFSIZE];
        time_t recv_time;
        time_t now;
-       gint partial_recv;
        gchar *sanitized_uid = g_strdup(login); 
 
        subst_for_filename(sanitized_uid);
@@ -415,7 +416,6 @@ gchar *partial_get_filename(const gchar *server, const gchar *login,
                gchar tmp[POPBUFSIZE];
                strretchomp(buf);
                recv_time = RECV_TIME_NONE;
-               partial_recv = POP3_TOTALLY_RECEIVED;
                
                if (sscanf(buf, "%s\t%ld\t%s", uidl, (long int *) &recv_time, 
                           tmp) < 2) {