* src/folder.c
[claws.git] / src / folder.c
index 96f0f7f03a04d860336953c0ca79bb6a04fe5adf..9fc79f721e3e2aa85dc204c152b576800ae56c5b 100644 (file)
@@ -1675,13 +1675,15 @@ gint folder_item_remove_msg(FolderItem *item, gint num)
        ret = folder->remove_msg(folder, item, num);
 
        msginfo = msgcache_get_msg(item->cache, num);
-       if(MSG_IS_NEW(msginfo->flags))
-               item->new--;
-       if(MSG_IS_UNREAD(msginfo->flags))
-               item->unread--;
+       if(msginfo != NULL) {
+               if(MSG_IS_NEW(msginfo->flags))
+                       item->new--;
+               if(MSG_IS_UNREAD(msginfo->flags))
+                       item->unread--;
+               procmsg_msginfo_free(msginfo);
+               msgcache_remove_msg(item->cache, num);
+       }
        item->total--;
-       procmsg_msginfo_free(msginfo);
-       msgcache_remove_msg(item->cache, num);
 
        return ret;
 }