2009-02-22 [colin] 3.7.0cvs68
authorColin Leroy <colin@colino.net>
Sun, 22 Feb 2009 18:47:11 +0000 (18:47 +0000)
committerColin Leroy <colin@colino.net>
Sun, 22 Feb 2009 18:47:11 +0000 (18:47 +0000)
* src/addrduplicates.c
* src/addressbook.c
* src/addrharvest.c
* src/codeconv.c
* src/compose.c
* src/filtering.c
* src/folder.c
* src/imap.c
* src/imap_gtk.c
* src/importldif.c
* src/jpilot.c
* src/mainwindow.c
* src/matcher.c
* src/mbox.c
* src/messageview.c
* src/mh_gtk.c
* src/prefs_common.c
* src/prefs_filtering.c
* src/prefs_gtk.c
* src/printing.c
* src/privacy.c
* src/procmime.c
* src/procmsg.c
* src/summaryview.c
* src/textview.c
* src/undo.c
* src/wizard.c
* src/common/md5.c
* src/common/socket.c
* src/common/template.c
* src/etpan/imap-thread.c
* src/gtk/gtkaspell.c
* src/gtk/gtkcmctree.c
* src/gtk/gtksctree.c
* src/gtk/inputdialog.c
* src/plugins/pgpcore/sgpgme.c
* src/plugins/pgpmime/pgpmime.c
* src/plugins/smime/smime.c
* src/plugins/spamassassin/spamassassin.c
Fix errors caught by Coverity: NULL checks, leaks, overruns,
uninitialised accesses

42 files changed:
ChangeLog
PATCHSETS
configure.ac
src/addrduplicates.c
src/addressbook.c
src/addrharvest.c
src/codeconv.c
src/common/md5.c
src/common/socket.c
src/common/template.c
src/compose.c
src/etpan/imap-thread.c
src/filtering.c
src/folder.c
src/gtk/gtkaspell.c
src/gtk/gtkcmctree.c
src/gtk/gtksctree.c
src/gtk/inputdialog.c
src/imap.c
src/imap_gtk.c
src/importldif.c
src/jpilot.c
src/mainwindow.c
src/matcher.c
src/mbox.c
src/messageview.c
src/mh_gtk.c
src/plugins/pgpcore/sgpgme.c
src/plugins/pgpmime/pgpmime.c
src/plugins/smime/smime.c
src/plugins/spamassassin/spamassassin.c
src/prefs_common.c
src/prefs_filtering.c
src/prefs_gtk.c
src/printing.c
src/privacy.c
src/procmime.c
src/procmsg.c
src/summaryview.c
src/textview.c
src/undo.c
src/wizard.c

index 8116008..bd05c9a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,47 @@
+2009-02-22 [colin]     3.7.0cvs68
+
+       * src/addrduplicates.c
+       * src/addressbook.c
+       * src/addrharvest.c
+       * src/codeconv.c
+       * src/compose.c
+       * src/filtering.c
+       * src/folder.c
+       * src/imap.c
+       * src/imap_gtk.c
+       * src/importldif.c
+       * src/jpilot.c
+       * src/mainwindow.c
+       * src/matcher.c
+       * src/mbox.c
+       * src/messageview.c
+       * src/mh_gtk.c
+       * src/prefs_common.c
+       * src/prefs_filtering.c
+       * src/prefs_gtk.c
+       * src/printing.c
+       * src/privacy.c
+       * src/procmime.c
+       * src/procmsg.c
+       * src/summaryview.c
+       * src/textview.c
+       * src/undo.c
+       * src/wizard.c
+       * src/common/md5.c
+       * src/common/socket.c
+       * src/common/template.c
+       * src/etpan/imap-thread.c
+       * src/gtk/gtkaspell.c
+       * src/gtk/gtkcmctree.c
+       * src/gtk/gtksctree.c
+       * src/gtk/inputdialog.c
+       * src/plugins/pgpcore/sgpgme.c
+       * src/plugins/pgpmime/pgpmime.c
+       * src/plugins/smime/smime.c
+       * src/plugins/spamassassin/spamassassin.c
+               Fix errors caught by Coverity: NULL checks, leaks, overruns,
+               uninitialised accesses
+
 2009-02-17 [colin]     3.7.0cvs67
 
        * src/compose.c
index 62c0dfd..542ef79 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.207.2.211 -r 1.207.2.212 src/folderview.c;  cvs diff -u -r 1.395.2.406 -r 1.395.2.407 src/summaryview.c;  ) > 3.7.0cvs65.patchset
 ( cvs diff -u -r 1.10.2.19 -r 1.10.2.20 src/privacy.c;  cvs diff -u -r 1.1.2.25 -r 1.1.2.26 src/plugins/pgpcore/select-keys.c;  cvs diff -u -r 1.1.2.61 -r 1.1.2.62 src/plugins/pgpcore/sgpgme.c;  ) > 3.7.0cvs66.patchset
 ( cvs diff -u -r 1.382.2.499 -r 1.382.2.500 src/compose.c;  ) > 3.7.0cvs67.patchset
+( cvs diff -u -r 1.1.2.14 -r 1.1.2.15 src/addrduplicates.c;  cvs diff -u -r 1.60.2.130 -r 1.60.2.131 src/addressbook.c;  cvs diff -u -r 1.6.10.20 -r 1.6.10.21 src/addrharvest.c;  cvs diff -u -r 1.65.2.66 -r 1.65.2.67 src/codeconv.c;  cvs diff -u -r 1.382.2.500 -r 1.382.2.501 src/compose.c;  cvs diff -u -r 1.60.2.50 -r 1.60.2.51 src/filtering.c;  cvs diff -u -r 1.213.2.188 -r 1.213.2.189 src/folder.c;  cvs diff -u -r 1.179.2.239 -r 1.179.2.240 src/imap.c;  cvs diff -u -r 1.1.2.62 -r 1.1.2.63 src/imap_gtk.c;  cvs diff -u -r 1.14.2.22 -r 1.14.2.23 src/importldif.c;  cvs diff -u -r 1.18.2.28 -r 1.18.2.29 src/jpilot.c;  cvs diff -u -r 1.274.2.298 -r 1.274.2.299 src/mainwindow.c;  cvs diff -u -r 1.75.2.63 -r 1.75.2.64 src/matcher.c;  cvs diff -u -r 1.28.2.46 -r 1.28.2.47 src/mbox.c;  cvs diff -u -r 1.94.2.198 -r 1.94.2.199 src/messageview.c;  cvs diff -u -r 1.2.2.35 -r 1.2.2.36 src/mh_gtk.c;  cvs diff -u -r 1.204.2.186 -r 1.204.2.187 src/prefs_common.c;  cvs diff -u -r 1.59.2.76 -r 1.59.2.77 src/prefs_filtering.c;  cvs diff -u -r 1.10.2.39 -r 1.10.2.40 src/prefs_gtk.c;  cvs diff -u -r 1.1.2.21 -r 1.1.2.22 src/printing.c;  cvs diff -u -r 1.10.2.20 -r 1.10.2.21 src/privacy.c;  cvs diff -u -r 1.49.2.124 -r 1.49.2.125 src/procmime.c;  cvs diff -u -r 1.150.2.112 -r 1.150.2.113 src/procmsg.c;  cvs diff -u -r 1.395.2.407 -r 1.395.2.408 src/summaryview.c;  cvs diff -u -r 1.96.2.215 -r 1.96.2.216 src/textview.c;  cvs diff -u -r 1.13.2.19 -r 1.13.2.20 src/undo.c;  cvs diff -u -r 1.1.2.78 -r 1.1.2.79 src/wizard.c;  cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/common/md5.c;  cvs diff -u -r 1.13.2.43 -r 1.13.2.44 src/common/socket.c;  cvs diff -u -r 1.2.4.29 -r 1.2.4.30 src/common/template.c;  cvs diff -u -r 1.1.4.109 -r 1.1.4.110 src/etpan/imap-thread.c;  cvs diff -u -r 1.9.2.65 -r 1.9.2.66 src/gtk/gtkaspell.c;  cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/gtk/gtkcmctree.c;  cvs diff -u -r 1.1.4.54 -r 1.1.4.55 src/gtk/gtksctree.c;  cvs diff -u -r 1.2.2.36 -r 1.2.2.37 src/gtk/inputdialog.c;  cvs diff -u -r 1.1.2.62 -r 1.1.2.63 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.53 -r 1.1.2.54 src/plugins/pgpmime/pgpmime.c;  cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/smime/smime.c;  cvs diff -u -r 1.18.2.62 -r 1.18.2.63 src/plugins/spamassassin/spamassassin.c;  ) > 3.7.0cvs68.patchset
index 2d859fe..95aec71 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=67
+EXTRA_VERSION=68
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8674a5e..e745fba 100644 (file)
@@ -177,7 +177,7 @@ static void destroy_addr_hash_val(gpointer value)
 
        for(walk = list; walk; walk = walk->next) {
                AddrDupListEntry *entry = (AddrDupListEntry*) walk->data;
-               if(entry->book_path)
+               if(entry && entry->book_path)
                        g_free(entry->book_path);
                if(entry)
                        g_free(entry);
@@ -843,10 +843,11 @@ gboolean addrduplicates_delete_item_person(ItemPerson *item, AddressDataSource *
 {
        AddressBookFile *abf;
        AddressInterface *iface;
-
+       if (!ds)
+               return FALSE;
        /* Test for read only */
        iface = ds->interface;
-       if( iface->readOnly ) {
+       if( iface && iface->readOnly ) {
                alertpanel( _("Delete address"),
                            _("This address data is readonly and cannot be deleted."),
                            GTK_STOCK_CLOSE, NULL, NULL );
index a549681..084fc2f 100644 (file)
@@ -2557,8 +2557,6 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree,
 
        if (obj->type == ADDR_INTERFACE) {
                AdapterInterface *adapter = ADAPTER_INTERFACE(obj);
-               if( !adapter )
-                       goto just_set_sens;
                iface = adapter->interface;
                if( !iface )
                        goto just_set_sens;
@@ -3216,7 +3214,8 @@ static void addressbook_new_address_cb( GtkAction *action, gpointer data ) {
 
                                pobj = gtk_cmctree_node_get_row_data(GTK_CMCTREE(addrbook.ctree), addrbook.treeSelected);
                                ds = addressbook_find_datasource( GTK_CMCTREE_NODE(addrbook.treeSelected) );
-                               abf = ds->rawDataSource;
+                               if (ds)
+                                       abf = ds->rawDataSource;
                        }
 #endif
                        person = addressbook_edit_person( abf, folder, NULL, FALSE,
@@ -3266,7 +3265,8 @@ static void addressbook_new_address_cb( GtkAction *action, gpointer data ) {
                                return;
                        pobj = gtk_cmctree_node_get_row_data(GTK_CMCTREE(addrbook.ctree), addrbook.treeSelected);
                        ds = addressbook_find_datasource( GTK_CMCTREE_NODE(addrbook.treeSelected) );
-                       abf = ds->rawDataSource;
+                       if (ds)
+                               abf = ds->rawDataSource;
                }
 #endif
                person = addressbook_edit_person( abf, folder, NULL, FALSE,
@@ -4325,14 +4325,18 @@ static GtkCMCTreeNode *addressbook_node_add_folder(
        ItemFolder *rootFolder;
 
        /* Only visible folders */
-       if( itemFolder->isHidden ) return NULL;
+       if( itemFolder == NULL || itemFolder->isHidden ) 
+               return NULL;
 
-       if( ds == NULL ) return NULL;
-       if( node == NULL || itemFolder == NULL ) return NULL;
+       if( ds == NULL ) 
+               return NULL;
+       if( node == NULL || itemFolder == NULL ) 
+               return NULL;
 
        /* Determine object type */
        atci = addrbookctl_lookup( otype );
-       if( atci == NULL ) return NULL;
+       if( atci == NULL ) 
+               return NULL;
 
        rootFolder = addrindex_ds_get_root_folder( ds );
        if( itemFolder == rootFolder ) {
@@ -4718,7 +4722,7 @@ static void addressbook_browse_entry_cb( GtkAction *action, gpointer data)
                return;
 
        iface = ds->interface;
-       if(! iface->haveLibrary )
+       if(!iface || !iface->haveLibrary )
                return;
 
        person = NULL;
index d4cb482..274054c 100644 (file)
@@ -499,8 +499,8 @@ static void addrharvest_parse_address(
 
                /* Copy into buffer */
                bufLen = ( size_t ) ( ep - bp );
-               if( bufLen > ADDR_BUFFSIZE ) {
-                       bufLen = ADDR_BUFFSIZE;
+               if( bufLen > ADDR_BUFFSIZE -1 ) {
+                       bufLen = ADDR_BUFFSIZE - 1;
                }
                strncpy( buffer, bp, bufLen );
                buffer[ bufLen ] = '\0';
index 50bb708..4f8b2da 100644 (file)
@@ -1547,6 +1547,7 @@ void conv_encode_header_full(gchar *dest, gint len, const gchar *src,
        gboolean use_base64;
 
        g_return_if_fail(g_utf8_validate(src, -1, NULL) == TRUE);
+       g_return_if_fail(destp != NULL);
 
        if (MB_CUR_MAX > 1) {
                use_base64 = TRUE;
index c27244d..195de7b 100644 (file)
@@ -359,6 +359,7 @@ md5_hex_digest_file(char *hexdigest, const unsigned char *file)
 
        if (fd == -1) {
                FILE_OP_ERROR(file, "open");
+               g_free(buf);
                return -1;
        }
        
index c64e046..8b92afb 100644 (file)
@@ -468,11 +468,13 @@ static gboolean sock_check(GSource *source)
        SockInfo *sock = ((SockSource *)source)->sock;
        struct timeval timeout = {0, 0};
        fd_set fds;
-       GIOCondition condition = sock->condition;
+       GIOCondition condition = 0;
         
        if (!sock || !sock->sock)
                return FALSE;
 
+       condition = sock->condition;
+
        FD_ZERO(&fds);
        FD_SET(sock->sock, &fds);
 
index 22bd7b8..e2b209e 100644 (file)
@@ -74,6 +74,7 @@ static Template *template_load(gchar *filename)
        if (!tmpl->name) {
                g_warning("wrong template format\n");
                template_free(tmpl);
+               fclose(fp);
                return NULL;
        }
 
@@ -81,6 +82,7 @@ static Template *template_load(gchar *filename)
                if (ferror(fp)) {
                        FILE_OP_ERROR(filename, "fread");
                        template_free(tmpl);
+                       fclose(fp);
                        return NULL;
                }
        }
@@ -204,6 +206,17 @@ if (!(func)) \
 } \
 }
 
+#define TRY_NO_CLOSE(func) { \
+if (!(func)) \
+{ \
+       g_warning("Failed to write template to file\n"); \
+       if (new) claws_unlink(new); \
+       g_free(new); \
+       g_free(filename); \
+       return; \
+} \
+}
+
 static void template_write_config(GSList *tmpl_list)
 {
        const gchar *path;
@@ -264,7 +277,7 @@ static void template_write_config(GSList *tmpl_list)
                } else {
                        TRY(fwrite("", sizeof(gchar), 1, fp) == 1);
                }
-               TRY(fclose(fp) != EOF);
+               TRY_NO_CLOSE(fclose(fp) != EOF);
 
                if (new) {
                        claws_unlink(filename);
index 8a1db79..6f45e19 100644 (file)
@@ -1198,7 +1198,7 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
 
 static void compose_force_signing(Compose *compose, PrefsAccount *account, const gchar *system)
 {
-       gchar *privacy = NULL;
+       const gchar *privacy = NULL;
 
        if (system)
                privacy = system;
@@ -1816,8 +1816,15 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_
        g_return_val_if_fail(account != NULL, NULL);
 
        for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
-               MSG_UNSET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_REPLIED);
-               MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
+               if (msginfo->data) {
+                       MSG_UNSET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_REPLIED);
+                       MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
+               }
+       }
+
+       if (msginfo_list == NULL || msginfo_list->data == NULL) {
+               g_warning("no msginfo_list");
+               return NULL;
        }
 
        compose = compose_create(account, ((MsgInfo *)msginfo_list->data)->folder, COMPOSE_FORWARD, FALSE);
@@ -3528,15 +3535,16 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
        while (child && child->node->children && (child->type == MIMETYPE_MULTIPART))
                child = (MimeInfo *)child->node->children->data;
 
-       if (child->type == MIMETYPE_TEXT) {
-               firsttext = child;
-               debug_print("First text part found\n");
-       } else if (compose->mode == COMPOSE_REEDIT &&
-                child->type == MIMETYPE_APPLICATION &&
-                !g_ascii_strcasecmp(child->subtype, "pgp-encrypted")) {
-               encrypted = (MimeInfo *)child->node->parent->data;
+       if (child) {
+               if (child->type == MIMETYPE_TEXT) {
+                       firsttext = child;
+                       debug_print("First text part found\n");
+               } else if (compose->mode == COMPOSE_REEDIT &&
+                        child->type == MIMETYPE_APPLICATION &&
+                        !g_ascii_strcasecmp(child->subtype, "pgp-encrypted")) {
+                       encrypted = (MimeInfo *)child->node->parent->data;
+               }
        }
-     
        child = (MimeInfo *) mimeinfo->node->children->data;
        while (child != NULL) {
                gint err;
@@ -5514,9 +5522,9 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        if (compose->newsgroup_list) {
                 if (compose->account->protocol == A_NNTP)
                         newsac = compose->account;
-                else if (!newsac->protocol != A_NNTP) {
+                else {
                        lock = FALSE;
-                       alertpanel_error(_("No account for posting news available!"));
+                       alertpanel_error(_("Selected account isn't NNTP: Posting is impossible."));
                        return -1;
                }                       
        }
@@ -10192,8 +10200,6 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
 
        /* strangely, testing data->type == gdk_atom_intern("text/uri-list", TRUE)
         * does not work */
-       debug_print("drop: %s (%s)\n", gdk_atom_name(data->type)?gdk_atom_name(data->type):"nul",
-               (gchar *)(data->data?data->data:"nul"));
 #ifndef G_OS_WIN32
        if (gdk_atom_name(data->type) && !strcmp(gdk_atom_name(data->type), "text/uri-list")) {
 #else
@@ -10202,8 +10208,6 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
                AlertValue val = G_ALERTDEFAULT;
 
                list = uri_list_extract_filenames((const gchar *)data->data);
-               debug_print("list: %p (%s)\n", list, 
-                       (gchar *)(data->data?data->data:"nul"));
                if (list == NULL && strstr((gchar *)(data->data), "://")) {
                        /* Assume a list of no files, and data has ://, is a remote link */
                        gchar *tmpdata = g_strstrip(g_strdup((const gchar *)data->data));
index 085d188..ab21252 100644 (file)
@@ -1437,7 +1437,7 @@ int imap_threaded_select(Folder * folder, const char * mb,
                                        flag->fl_flag->fl_type == 6 &&
                                        !strcmp(flag->fl_flag->fl_data.fl_extension, "*"))
                                *can_create_flags = TRUE; 
-                       if (ok_flags) {
+                       if (flag->fl_flag && ok_flags) {
                                MsgPermFlags c_flag = 0;
                                switch (flag->fl_flag->fl_type) {
                                case MAILIMAP_FLAG_ANSWERED:
index 24c7644..d073532 100644 (file)
@@ -1016,6 +1016,9 @@ gchar * filteringprop_to_string(FilteringProp * prop)
        gchar *action_list_str;
        gchar *filtering_str;
 
+       if (prop == NULL)
+               return NULL;
+
         action_list_str = filteringaction_list_to_string(prop->action_list);
 
        if (action_list_str == NULL)
index d3ad2b7..a8d3366 100644 (file)
@@ -2156,13 +2156,13 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
                        MsgInfo *msginfo;
 
                        msginfo = msgcache_get_msg(item->cache, folder_cur_num);
-                       if (folder->klass->is_msg_changed && folder->klass->is_msg_changed(folder, item, msginfo)) {
+                       if (msginfo && folder->klass->is_msg_changed && folder->klass->is_msg_changed(folder, item, msginfo)) {
                                msgcache_remove_msg(item->cache, msginfo->msgnum);
                                new_list = g_slist_prepend(new_list, GINT_TO_POINTER(msginfo->msgnum));
                                procmsg_msginfo_free(msginfo);
 
                                debug_print("Remembering message %d to update...\n", folder_cur_num);
-                       } else {
+                       } else if (msginfo) {
                                exists_list = g_slist_prepend(exists_list, msginfo);
 
                                if(prefs_common.thread_by_subject &&
@@ -3405,7 +3405,7 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
                 GTuples *tuples;
 
                 tuples = g_relation_select(relation, msginfo, 0);
-               if (tuples->len > 0) {
+               if (tuples && tuples->len > 0) {
                        num = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
                        g_tuples_destroy(tuples);
                } else {
index b2a952c..9580ce1 100644 (file)
@@ -2074,7 +2074,7 @@ gboolean gtkaspell_change_dict(GtkAspell *gtkaspell, const gchar *dictionary,
                dict->dictname = g_strdup(dictionary);
        }
 
-       if (strchr(dict->fullname, '-')) {
+       if (dict->fullname && strchr(dict->fullname, '-')) {
                *(strchr(dict->fullname, '-')) = '\0';
                *(strchr(dict->dictname, '-')) = '\0';
        }
@@ -2129,7 +2129,7 @@ gboolean gtkaspell_change_alt_dict(GtkAspell *gtkaspell, const gchar *alt_dictio
                dict->dictname = g_strdup(alt_dictionary);
        }
 
-       if (strchr(dict->fullname, '-')) {
+       if (dict->fullname && strchr(dict->fullname, '-')) {
                *(strchr(dict->fullname, '-')) = '\0';
                *(strchr(dict->dictname, '-')) = '\0';
        }
index 8639fe5..bf82649 100644 (file)
@@ -2726,7 +2726,7 @@ real_tree_expand (GtkCMCTree     *ctree,
       list = (GList *)node;
       list->next = (GList *)(GTK_CMCTREE_ROW (node)->children);
 
-      if (visible)
+      if (visible && !GTK_CMCLIST_AUTO_RESIZE_BLOCKED (clist))
        {
          /* resize auto_resize columns if needed */
          for (i = 0; i < clist->columns; i++)
index e8fb574..8e2d072 100644 (file)
@@ -2986,7 +2986,7 @@ gtk_sctree_real_tree_expand (GtkCMCTree     *ctree,
       list = (GList *)node;
       list->next = (GList *)(GTK_CMCTREE_ROW (node)->children);
 
-      if (visible)
+      if (visible && !GTK_CMCLIST_AUTO_RESIZE_BLOCKED (clist))
        {
          /* resize auto_resize columns if needed */
          for (i = 0; i < clist->columns; i++)
index 59cd02b..952228a 100644 (file)
@@ -164,7 +164,7 @@ gchar *input_dialog_with_invisible_checkbtn(const gchar *title, const gchar *mes
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
 #endif
 
-       return input_dialog_open(title, message, checkbtn_label, default_string, *checkbtn_state, checkbtn_state);
+       return input_dialog_open(title, message, checkbtn_label, default_string, (checkbtn_state? *checkbtn_state:FALSE), checkbtn_state);
 }
 
 gchar *input_dialog_combo(const gchar *title, const gchar *message,
index bf558ca..e07e663 100644 (file)
@@ -531,11 +531,14 @@ static void unlock_session(IMAPSession *session)
 
 static void imap_disc_session_destroy(IMAPSession *session)
 {
-       RemoteFolder *rfolder = REMOTE_FOLDER(IMAP_SESSION(session)->folder);
-       
-       if (!rfolder)
+       RemoteFolder *rfolder = NULL;
+
+       if (session == NULL)
                return;
-       if (!session)
+
+       rfolder = REMOTE_FOLDER(IMAP_SESSION(session)->folder);
+       
+       if (rfolder == NULL)
                return;
        log_warning(LOG_PROTOCOL, _("IMAP4 connection broken\n"));
        SESSION(session)->state = SESSION_DISCONNECTED;
@@ -1969,8 +1972,10 @@ static gint imap_do_remove_msgs(Folder *folder, FolderItem *dest,
        }
 
        destdir = imap_get_real_path(session, IMAP_FOLDER(folder), dest->path, &ok);
-       if (is_fatal(ok))
+       if (is_fatal(ok)) {
+               g_free(destdir);
                return ok;
+       }
        for (cur = msglist; cur; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
                if (!MSG_IS_DELETED(msginfo->flags))
@@ -1986,12 +1991,14 @@ static gint imap_do_remove_msgs(Folder *folder, FolderItem *dest,
                        (session, IMAP_FOLDER_ITEM(msginfo->folder), numlist, IMAP_FLAG_DELETED, NULL, TRUE);
                if (ok != MAILIMAP_NO_ERROR) {
                        log_warning(LOG_PROTOCOL, _("can't set deleted flags\n"));
+                       g_free(destdir);
                        return ok;
                }
        } /* else we just need to expunge */
        ok = imap_cmd_expunge(session);
        if (ok != MAILIMAP_NO_ERROR) {
                log_warning(LOG_PROTOCOL, _("can't expunge\n"));
+               g_free(destdir);
                return ok;
        }
        
@@ -2181,8 +2188,10 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
                wildcard[1] = '%';
                wildcard[2] = '\0';
                real_path = imap_get_real_path(session, imapfolder, item->path, &r);
-               if (is_fatal(r))
+               if (is_fatal(r)) {
+                       g_free(real_path);
                        return r;
+               }
        } else {
                wildcard[0] = '%';
                wildcard[1] = '\0';
@@ -2201,6 +2210,7 @@ static gint imap_scan_tree_recursive(IMAPSession *session, FolderItem *item, gbo
        if (r != MAILIMAP_NO_ERROR) {
                imap_handle_error(SESSION(session), r);
                item_list = NULL;
+               g_free(real_path);
                return r;
        }
        else {
@@ -2324,8 +2334,10 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
                wildcard[1] = '%';
                wildcard[2] = '\0';
                real_path = imap_get_real_path(session, IMAP_FOLDER(folder), item->path, &r);
-               if (is_fatal(r))
+               if (is_fatal(r)) {
+                       g_free(real_path);
                        return NULL;
+               }
        } else {
                wildcard[0] = '%';
                wildcard[1] = '\0';
@@ -2345,6 +2357,7 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
 
        r = imap_threaded_list(folder, "", wildcard_path, &lep_list);
        if (r) {
+               g_free(real_path);
                statusbar_pop_all();
                return NULL;
        }
@@ -2364,6 +2377,7 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
                                imap_get_real_path(session, 
                                        IMAP_FOLDER(folder), cur_item->path, &r));
                if (is_fatal(r)) {
+                       g_free(real_path);
                        statusbar_pop_all();
                        return NULL;
                }
@@ -2375,6 +2389,7 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
        if (unsubs_only) {
                r = imap_threaded_lsub(folder, "", wildcard_path, &lep_list);
                if (r) {
+                       g_free(real_path);
                        statusbar_pop_all();
                        return NULL;
                }
@@ -2388,6 +2403,7 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
                        gchar *tmp = imap_get_real_path(session, 
                                        IMAP_FOLDER(folder), cur_item->path, &r);
                        if (r) {
+                               g_free(real_path);
                                statusbar_pop_all();
                                return NULL;
                        }
@@ -2403,6 +2419,7 @@ GList *imap_scan_subtree(Folder *folder, FolderItem *item, gboolean unsubs_only,
                }
        }
 
+       g_free(real_path);
        statusbar_pop_all();
 
        return child_list;
@@ -2610,11 +2627,14 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
        strtailchomp(dirpath, '/');
        Xstrdup_a(new_name, name, {
                g_free(dirpath); 
+               g_free(imap_path);
                return NULL;});
 
        separator = imap_get_path_separator(session, IMAP_FOLDER(folder), imap_path, &ok);
-       if (is_fatal(ok))
+       if (is_fatal(ok)) {
+               g_free(imap_path);
                return NULL;
+       }
        imap_path_separator_subst(imap_path, separator);
        /* remove trailing / for display */
        strtailchomp(new_name, '/');
@@ -2817,10 +2837,16 @@ gint imap_subscribe(Folder *folder, FolderItem *item, gchar *rpath, gboolean sub
        }
        if (item && item->path) {
                path = imap_get_real_path(session, IMAP_FOLDER(folder), item->path, &r);
-               if (!path || is_fatal(r))
+               if (!path)
                        return -1;
-               if (!strcmp(path, "INBOX") && sub == FALSE)
+               if (is_fatal(r)) {
+                       g_free(path);
+                       return -1;
+               }
+               if (!strcmp(path, "INBOX") && sub == FALSE) {
+                       g_free(path);
                        return -1;
+               }
                debug_print("%ssubscribing %s\n", sub?"":"un", path);
                r = imap_threaded_subscribe(folder, path, sub);
                g_free(path);
@@ -3204,7 +3230,7 @@ static gchar imap_get_path_separator(IMAPSession *session, IMAPFolder *folder, c
 
 static gchar *imap_get_real_path(IMAPSession *session, IMAPFolder *folder, const gchar *path, gint *ok)
 {
-       gchar *real_path;
+       gchar *real_path = NULL;
        gchar separator;
 
        g_return_val_if_fail(folder != NULL, NULL);
@@ -3212,7 +3238,8 @@ static gchar *imap_get_real_path(IMAPSession *session, IMAPFolder *folder, const
 
        real_path = imap_utf8_to_modified_utf7(path, FALSE);
        separator = imap_get_path_separator(session, folder, path, ok);
-       imap_path_separator_subst(real_path, separator);
+       if (ok == MAILIMAP_NO_ERROR)
+               imap_path_separator_subst(real_path, separator);
 
        return real_path;
 }
@@ -3257,6 +3284,9 @@ static gint imap_set_message_flags(IMAPSession *session,
                else
                        continue;
 
+               if (set_item == NULL)
+                       continue;
+
                statusbar_progress_all(set_item->set_first, total, 1);
 
                ok = imap_cmd_store(session, item, imapset,
@@ -3381,9 +3411,10 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder,
        guint mask = 0;
        
        real_path = imap_get_real_path(session, folder, path, &r);
-       if (is_fatal(r))
+       if (is_fatal(r)) {
+               g_free(real_path);
                return r;
-
+       }
        if (messages) {
                mask |= 1 << 0;
                *messages = 0;
@@ -3406,6 +3437,7 @@ static gint imap_status(IMAPSession *session, IMAPFolder *folder,
                r = imap_cmd_close(session);
                if (r != MAILIMAP_NO_ERROR) {
                        debug_print("close err %d\n", r);
+                       g_free(real_path);
                        return r;
                }
        }
index fc194e6..a10c822 100644 (file)
@@ -142,10 +142,10 @@ static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
 #define SET_SENS(name, sens) \
        cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
 
-       SET_SENS("FolderViewPopup/CreateNewFolder",   item->no_sub == FALSE);
-       SET_SENS("FolderViewPopup/RenameFolder",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
-       SET_SENS("FolderViewPopup/MoveFolder",      folder_is_normal && folder_item_parent(item) != NULL);
-       SET_SENS("FolderViewPopup/DeleteFolder",            item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/CreateNewFolder",   item && item->no_sub == FALSE);
+       SET_SENS("FolderViewPopup/RenameFolder",       item && item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/MoveFolder",      item && folder_is_normal && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/DeleteFolder",            item && item->stype == F_NORMAL && folder_item_parent(item) != NULL);
 
        SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item) == NULL);
        SET_SENS("FolderViewPopup/CheckNewFolders",  folder_item_parent(item) == NULL);
@@ -155,15 +155,15 @@ static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
                        item ? (folder_item_parent(item) != NULL
                        && folder_want_synchronise(item->folder))
                        : FALSE);
-       SET_SENS("FolderViewPopup/DownloadMessages", !item->no_select);
+       SET_SENS("FolderViewPopup/DownloadMessages", item && !item->no_select);
 
        SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item) == NULL);
        SET_SENS("FolderViewPopup/CheckNewFolders",  folder_item_parent(item) == NULL);
        SET_SENS("FolderViewPopup/RebuildTree",    folder_item_parent(item) == NULL);
        
-       SET_SENS("FolderViewPopup/Subscriptions/Unsubscribe",    item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/Subscriptions/Unsubscribe",    item && item->stype == F_NORMAL && folder_item_parent(item) != NULL);
        SET_SENS("FolderViewPopup/Subscriptions/Subscribe",    TRUE);
-       if (item->folder && item->folder->account)
+       if (item && item->folder && item->folder->account)
                cm_toggle_menu_set_active_full(ui_manager, "Popup/FolderViewPopup/Subscriptions/ShowOnlySubs",
                        item->folder->account->imap_subsonly);
 
index fd4ea25..03a9dbd 100644 (file)
@@ -206,6 +206,9 @@ static void imp_ldif_update_row( GtkCMCList *clist ) {
        row = impldif_dlg.rowIndSelect;
 
        rec = gtk_cmclist_get_row_data( clist, row );
+       if (!rec)
+               return;
+
        text[ FIELD_COL_RESERVED ] = "";
        text[ FIELD_COL_SELECT   ] = "";
        text[ FIELD_COL_FIELD    ] = rec->tagName;
index 861fba9..588dc2b 100644 (file)
@@ -758,11 +758,11 @@ static gint jpilot_read_db_files( JPilotFile *pilotFile, GList **records ) {
        char *buf;
        GList *temp_list;
        int num_records, recs_returned, i, num, r;
-       unsigned int offset, prev_offset, next_offset, rec_size;
+       unsigned int offset, prev_offset, next_offset = 0, rec_size;
        int out_of_order;
        long fpos;  /*file position indicator */
-       unsigned char attrib;
-       unsigned int unique_id;
+       unsigned char attrib = '\0';
+       unsigned int unique_id = 0;
        mem_rec_header *mem_rh, *temp_mem_rh, *last_mem_rh;
        record_header rh;
        RawDBHeader rdbh;
index 43733dc..eb58c33 100644 (file)
@@ -1323,7 +1323,7 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
        case GDK_space:
                BREAK_ON_MODIFIER_KEY();
                if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
-                       if (mainwin->folderview && mainwin->summaryview
+                       if (mainwin->folderview != NULL && mainwin->summaryview != NULL
                            && ((!mainwin->summaryview->displayed
                                && !mainwin->summaryview->selected) 
                                || (mainwin->summaryview->folder_item
index 6ae1c0d..99ed44f 100644 (file)
@@ -2372,8 +2372,17 @@ static void matcher_add_rulenames(const gchar *rcpath)
        FILE *dst = g_fopen(newpath, "wb");
        gchar buf[BUFFSIZE];
        int r;
+       if (src == NULL) {
+               perror("fopen");
+               if (dst)
+                       fclose(dst);
+               g_free(newpath);
+               return;
+       }
        if (dst == NULL) {
                perror("fopen");
+               if (src)
+                       fclose(src);
                g_free(newpath);
                return;
        }
index d339e4f..7832dae 100644 (file)
@@ -322,9 +322,15 @@ gint lock_mbox(const gchar *base, LockType type)
                        return -1;
                }
 
-               if (fprintf(lockfp, "%d\n", getpid()) < 0 ||
-                   fclose(lockfp) == EOF) {
-                       FILE_OP_ERROR(lockfile, "fopen||fclose");
+               if (fprintf(lockfp, "%d\n", getpid()) < 0) {
+                       FILE_OP_ERROR(lockfile, "fprintf");
+                       g_free(lockfile);
+                       fclose(lockfp);
+                       return -1;
+               }
+
+               if (fclose(lockfp) == EOF) {
+                       FILE_OP_ERROR(lockfile, "fclose");
                        g_free(lockfile);
                        return -1;
                }
index f0c6855..1e089e5 100644 (file)
@@ -1680,7 +1680,7 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
                return TRUE;
        }
 
-       if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK|GDK_SHIFT_MASK)) != 0)
+       if (event && (event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK|GDK_SHIFT_MASK)) != 0)
                return FALSE;
 
        g_signal_stop_emission_by_name(G_OBJECT(widget),
index 8393897..6890203 100644 (file)
@@ -110,9 +110,9 @@ static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
        cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
 
        SET_SENS("FolderViewPopup/CreateNewFolder",   TRUE);
-       SET_SENS("FolderViewPopup/RenameFolder",       item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/RenameFolder",       item && item->stype == F_NORMAL && folder_item_parent(item) != NULL);
        SET_SENS("FolderViewPopup/MoveFolder",      folder_is_normal && folder_item_parent(item) != NULL);
-       SET_SENS("FolderViewPopup/DeleteFolder",            item->stype == F_NORMAL && folder_item_parent(item) != NULL);
+       SET_SENS("FolderViewPopup/DeleteFolder",            item && item->stype == F_NORMAL && folder_item_parent(item) != NULL);
 
        SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item) == NULL);
        SET_SENS("FolderViewPopup/CheckNewFolders",  folder_item_parent(item) == NULL);
index 8d94838..6a2767a 100644 (file)
@@ -254,9 +254,17 @@ gchar *sgpgme_sigstat_info_full(gpgme_ctx_t ctx, gpgme_verify_result_t status)
        gint i = 0;
        gchar *ret;
        GString *siginfo;
-       gpgme_signature_t sig = status->signatures;
-       
+       gpgme_signature_t sig = NULL;
+
        siginfo = g_string_sized_new(64);
+       if (status == NULL) {
+               g_string_append_printf(siginfo,
+                       _("Error checking signature: no status\n"));
+               goto bail;
+        }
+
+       sig = status->signatures;
+       
        while (sig) {
                gpgme_user_id_t user = NULL;
                gpgme_key_t key;
@@ -292,12 +300,12 @@ gchar *sgpgme_sigstat_info_full(gpgme_ctx_t ctx, gpgme_verify_result_t status)
                case GPG_ERR_KEY_EXPIRED:
                        g_string_append_printf(siginfo,
                                _("Good signature from uid \"%s\" (Validity: %s)\n"),
-                               uid, get_validity_str(user->validity));
+                               uid, get_validity_str(user?user->validity:GPGME_VALIDITY_UNKNOWN));
                        break;
                case GPG_ERR_SIG_EXPIRED:
                        g_string_append_printf(siginfo,
                                _("Expired signature from uid \"%s\" (Validity: %s)\n"),
-                               uid, get_validity_str(user->validity));
+                               uid, get_validity_str(user?user->validity:GPGME_VALIDITY_UNKNOWN));
                        break;
                case GPG_ERR_BAD_SIGNATURE:
                        g_string_append_printf(siginfo,
@@ -542,11 +550,11 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account,
                        if (!err && key2 && key2->protocol == gpgme_get_protocol(ctx) &&
                            !key2->expired && !key2->revoked && !key2->disabled)
                                break;
-                       if (!err && key && key2->protocol != gpgme_get_protocol(ctx)) {
+                       if (!err && key2 && key2->protocol != gpgme_get_protocol(ctx)) {
                                debug_print("skipping a key (wrong protocol %d)\n", key2->protocol);
                                gpgme_key_release(key2);
                        }
-                       if (!err && key && (key2->expired || key2->revoked || key2->disabled)) {
+                       if (!err && key2 && (key2->expired || key2->revoked || key2->disabled)) {
                                        debug_print("skipping a key");
                                        if (key2->expired) 
                                                debug_print(" expired");
index ebc3712..9f4d1ad 100644 (file)
@@ -199,6 +199,7 @@ static gint pgpmime_check_signature(MimeInfo *mimeinfo)
        boundary = g_hash_table_lookup(parent->typeparameters, "boundary");
        if (!boundary) {
                privacy_set_error(_("Signature boundary not found."));
+               fclose(fp);
                return 0;
        }
        textstr = get_canonical_content(fp, boundary);
@@ -350,6 +351,7 @@ static MimeInfo *pgpmime_decrypt(MimeInfo *mimeinfo)
 
        if (fprintf(dstfp, "MIME-Version: 1.0\n") < 0) {
                FILE_OP_ERROR(fname, "fprintf");
+               fclose(dstfp);
                privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                g_free(fname);
                gpgme_data_release(plain);
@@ -362,6 +364,7 @@ static MimeInfo *pgpmime_decrypt(MimeInfo *mimeinfo)
        if (len > 0) {
                if (fwrite(chars, 1, len, dstfp) < len) {
                        FILE_OP_ERROR(fname, "fwrite");
+                       fclose(dstfp);
                        privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                        g_free(fname);
                        gpgme_data_release(plain);
index e4199bd..b3a19f9 100644 (file)
@@ -236,7 +236,7 @@ static gint smime_check_signature(MimeInfo *mimeinfo)
        } else {
                textstr = get_canonical_content(fp, boundary);
        }
-       err = gpgme_data_new_from_mem(&textdata, textstr, strlen(textstr), 0);
+       err = gpgme_data_new_from_mem(&textdata, textstr, textstr?strlen(textstr):0, 0);
        
        if (err) {
                debug_print ("gpgme_data_new_from_mem failed: %s\n",
@@ -271,6 +271,10 @@ static gint smime_check_signature(MimeInfo *mimeinfo)
                                newinfo = procmime_scan_file(tmp_file);
                                decinfo = g_node_first_child(newinfo->node) != NULL ?
                                        g_node_first_child(newinfo->node)->data : NULL;
+
+                               if (decinfo == NULL)
+                                       return -1;
+
                                g_node_unlink(decinfo->node);
                                procmime_mimeinfo_free_all(newinfo);
                                decinfo->tmp = TRUE;
@@ -442,6 +446,7 @@ static MimeInfo *smime_decrypt(MimeInfo *mimeinfo)
        if (fprintf(dstfp, "MIME-Version: 1.0\n") < 0) {
                FILE_OP_ERROR(fname, "fprintf");
                g_free(fname);
+               fclose(dstfp);
                gpgme_data_release(plain);
                gpgme_release(ctx);
                debug_print("can't close!\n");
@@ -586,7 +591,7 @@ gboolean smime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from
 
        fclose(fp);
 
-       gpgme_data_new_from_mem(&gpgtext, textstr, strlen(textstr), 0);
+       gpgme_data_new_from_mem(&gpgtext, textstr, textstr?strlen(textstr):0, 0);
        gpgme_data_new(&gpgsig);
        gpgme_new(&ctx);
        gpgme_set_armor(ctx, TRUE);
@@ -818,7 +823,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        fclose(fp);
 
        /* encrypt data */
-       gpgme_data_new_from_mem(&gpgtext, textstr, strlen(textstr), 0);
+       gpgme_data_new_from_mem(&gpgtext, textstr, textstr?strlen(textstr):0, 0);
        gpgme_data_new(&gpgenc);
        gpgme_data_rewind(gpgtext);
        
index e20c980..5bb4ff0 100644 (file)
@@ -267,6 +267,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                
                if (whitelisted) {
                        debug_print("message is ham (whitelisted)\n");
+                       fclose(fp);
                        return FALSE;
                }
        }
index be9f07c..503ec80 100644 (file)
@@ -1454,8 +1454,8 @@ gchar *pref_get_pref_from_textview(GtkTextView *textview)
        gtk_text_buffer_get_iter_at_offset(buffer, &end, -1);
        tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
        out = malloc(2*strlen(tmp)+1);
-       
-       pref_get_escaped_pref(out, tmp);
+       if (out)
+               pref_get_escaped_pref(out, tmp);
        g_free(tmp);
 
        return out?out:"";
@@ -1471,8 +1471,9 @@ gchar *pref_get_pref_from_entry(GtkEntry *entry)
 
        tmp = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
        out = malloc(2*strlen(tmp)+1);
-
-       pref_get_escaped_pref(out, tmp);
+       
+       if (out)
+               pref_get_escaped_pref(out, tmp);
        g_free(tmp);
 
        return out?out:"";
index 4b673db..3943631 100644 (file)
@@ -1034,14 +1034,15 @@ static void prefs_filtering_set_list(void)
 static gint prefs_filtering_list_view_set_row(gint row, FilteringProp * prop)
 {
        GtkTreeView *list_view = GTK_TREE_VIEW(filtering.cond_list_view);
-       gchar *str;
+       gchar *str = NULL;
        GtkListStore *list_store;
        gchar *name = NULL;
        gint account_id = 0;
        gchar *account_name = (gchar *)Q_("Filtering Account Menu|All");
        gboolean enabled = TRUE;
 
-       str = filteringprop_to_string(prop);
+       if (prop)
+               str = filteringprop_to_string(prop);
        if (str == NULL)
                return -1;
 
index b797128..20c6eab 100644 (file)
@@ -965,10 +965,12 @@ static void prefs_destroy_file_cache(gpointer to_free)
 
 static int prefs_cache_sections(GHashTable *file_cache, const gchar *rcfile)
 {
-       FILE *fp = g_fopen(rcfile, "rb");
+       FILE *fp = NULL;
        gchar buf[PREFSBUFSIZE];
        GHashTable *section_cache = NULL;
 
+       if (rcfile)
+               fp = g_fopen(rcfile, "rb");
        if (!fp) {
                debug_print("cache: %s: %s\n", rcfile?rcfile:"(null)", strerror(errno));
                return -1;
index a6e0945..7dc6c43 100644 (file)
@@ -1131,7 +1131,7 @@ static void printing_layout_set_text_attributes(PrintData *print_data, GtkPrintC
     gboolean fg_set, bg_set, under_set, strike_set, weight_set;
     GSList *tags, *tag_walk;
     GtkTextTag *tag;
-    GdkColor *color;
+    GdkColor *color = NULL;
     PangoUnderline underline;
     gboolean strikethrough;
     gint weight;
@@ -1186,7 +1186,7 @@ static void printing_layout_set_text_attributes(PrintData *print_data, GtkPrintC
            if(attr->klass->type == PANGO_ATTR_FOREGROUND) {
              attr_color = (PangoAttrColor*) attr;
              g_object_get(G_OBJECT(tag), "foreground_gdk", &color, NULL);
-             if(printing_is_pango_gdk_color_equal(&(attr_color->color), color)) {
+             if(color && printing_is_pango_gdk_color_equal(&(attr_color->color), color)) {
                attr->end_index = printing_text_iter_get_offset_bytes(print_data, &iter);
                pango_attr_list_insert(attr_list, attr);
                found = TRUE;
@@ -1300,6 +1300,7 @@ static void printing_layout_set_text_attributes(PrintData *print_data, GtkPrintC
                     "foreground-set", &fg_set,
                     "underline-set", &under_set,
                     "strikethrough-set", &strike_set,
+                    "weight-set", &weight_set,
                     NULL);
        if(fg_set) {
          g_object_get(G_OBJECT(tag), "foreground-gdk", &color, NULL);
index 4bf73f0..ac14123 100644 (file)
@@ -177,7 +177,8 @@ void privacy_msginfo_get_signed_state(MsgInfo *msginfo, gchar **system)
 {
        struct SignedState sstate;
        MimeInfo *mimeinfo = procmime_scan_message(msginfo);
-
+       if (!mimeinfo)
+               return;
        sstate.msginfo = msginfo;
        sstate.system = system;
        g_node_children_foreach(mimeinfo->node, G_TRAVERSE_ALL, msginfo_set_signed_flag, &sstate);
index b7e72a1..80d92c3 100644 (file)
@@ -476,15 +476,18 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                return FALSE;
        }
 
-       if (mimeinfo->content == MIMECONTENT_FILE) {
+       if (mimeinfo->content == MIMECONTENT_FILE && mimeinfo->data.filename) {
                if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
                        g_warning("Can't open file %s\n", mimeinfo->data.filename);
+                       fclose(outfp);
                        return FALSE;
                }
        } else if (mimeinfo->content == MIMECONTENT_MEM) {
                infp = str_open_as_stream(mimeinfo->data.mem);
-               if (infp == NULL)
+               if (infp == NULL) {
+                       fclose(outfp);
                        return FALSE;
+               }
        }
 
        if (encoding == ENC_BASE64) {
@@ -499,6 +502,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                                if (canonicalize_file(mimeinfo->data.filename, tmp_file) < 0) {
                                        g_free(tmp_file);
                                        fclose(infp);
+                                       fclose(outfp);
                                        return FALSE;
                                }
                                if ((tmp_fp = g_fopen(tmp_file, "rb")) == NULL) {
@@ -506,6 +510,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                                        claws_unlink(tmp_file);
                                        g_free(tmp_file);
                                        fclose(infp);
+                                       fclose(outfp);
                                        return FALSE;
                                }
                        } else {
@@ -514,8 +519,10 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                                infp = str_open_as_stream(out);
                                tmp_fp = infp;
                                g_free(out);
-                               if (infp == NULL)
+                               if (infp == NULL) {
+                                       fclose(outfp);
                                        return FALSE;
+                               }
                        }
                }
 
@@ -1625,8 +1632,8 @@ static void parse_parameters(const gchar *parameters, GHashTable *table)
                down_attr = g_utf8_strdown(attribute, -1);
                orig_down_attr = down_attr;
        
-               len = strlen(down_attr);
-               if (down_attr[len - 1] == '*') {
+               len = down_attr ? strlen(down_attr):0;
+               if (len > 0 && down_attr[len - 1] == '*') {
                        gchar *srcpos, *dstpos, *endpos;
 
                        convert = TRUE;
index e1e468a..5f741fe 100644 (file)
@@ -1647,7 +1647,7 @@ send_mail:
        }
 
        fseek(fp, filepos, SEEK_SET);
-       if (newsgroup_list && (mailval == 0)) {
+       if (newsgroup_list && newsac && (mailval == 0)) {
                Folder *folder;
                gchar *tmp = NULL;
                FILE *tmpfp;
index b779441..d48669f 100644 (file)
@@ -5003,7 +5003,7 @@ static void summary_thread_build(SummaryView *summaryview)
                        }
                }
 
-               if (prefs_common.thread_by_subject && parent == NULL) {
+               if (msginfo && prefs_common.thread_by_subject && parent == NULL) {
                        parent = subject_table_lookup
                                (summaryview->subject_table,
                                 msginfo->subject);
@@ -6315,6 +6315,8 @@ static gboolean summary_button_released(GtkWidget *ctree, GdkEventButton *event,
 
 gboolean summary_pass_key_press_event(SummaryView *summaryview, GdkEventKey *event)
 {
+       if (!summaryview)
+               return FALSE;
        if (summary_is_list(summaryview))
                return summary_key_pressed(summaryview->ctree, event, summaryview);
        else
index d3672e0..f977aef 100644 (file)
@@ -1535,16 +1535,18 @@ do_quote:
                        } else {
                                g_print("oops (%d %d)\n",
                                        real_quotelevel, textview->prev_quote_level);
-                       }               
-                       if (lasturi->is_quote == FALSE) {
-                               textview->prev_quote_level = -1;
-                               goto do_quote;
+                       }       
+                       if (lasturi) {  
+                               if (lasturi->is_quote == FALSE) {
+                                       textview->prev_quote_level = -1;
+                                       goto do_quote;
+                               }
+                               e_len = lasturi->data ? strlen(lasturi->data):0;
+                               n_len = strlen(buf);
+                               lasturi->data = g_realloc((gchar *)lasturi->data, e_len + n_len + 1);
+                               strcpy((gchar *)lasturi->data + e_len, buf);
+                               *((gchar *)lasturi->data + e_len + n_len) = '\0';
                        }
-                       e_len = lasturi->data ? strlen(lasturi->data):0;
-                       n_len = strlen(buf);
-                       lasturi->data = g_realloc((gchar *)lasturi->data, e_len + n_len + 1);
-                       strcpy((gchar *)lasturi->data + e_len, buf);
-                       *((gchar *)lasturi->data + e_len + n_len) = '\0';
                }
        } else {
                textview_make_clickable_parts(textview, fg_color, "link", buf, FALSE);
index bbb6022..2652614 100644 (file)
@@ -552,8 +552,9 @@ void undo_insert_text_cb(GtkTextBuffer *textbuf, GtkTextIter *iter,
                        last_undo->text = gtk_text_buffer_get_text(textbuf, &start, &end, FALSE);
                        debug_print("add:undo upd %d-%d\n", last_undo->start_pos, last_undo->end_pos);
                        return;
-               } else debug_print("add:last: %d, %d-%d (%d)\n", last_undo->action,
-                       last_undo->start_pos, last_undo->end_pos, pos);
+               } else if (last_undo)
+                       debug_print("add:last: %d, %d-%d (%d)\n", last_undo->action,
+                               last_undo->start_pos, last_undo->end_pos, pos);
        } 
        Xstrndup_a(text_to_insert, new_text, new_text_length, return);
        debug_print("add:undo add %d-%ld\n", pos, pos + g_utf8_strlen(text_to_insert, -1));
@@ -588,8 +589,9 @@ void undo_delete_text_cb(GtkTextBuffer *textbuf, GtkTextIter *start,
                        last_undo->text = gtk_text_buffer_get_text(textbuf, &start, &end, FALSE);
                        debug_print("del:undo upd %d-%d\n", last_undo->start_pos, last_undo->end_pos);
                        return;
-               } else debug_print("del:last: %d, %d-%d (%d)\n", last_undo->action,
-                       last_undo->start_pos, last_undo->end_pos, start_pos);
+               } else if (last_undo)
+                       debug_print("del:last: %d, %d-%d (%d)\n", last_undo->action,
+                               last_undo->start_pos, last_undo->end_pos, start_pos);
                
        } 
        debug_print("del:undo add %d-%d\n", start_pos, end_pos);
index deb3a7b..601e4cc 100644 (file)
@@ -317,7 +317,8 @@ static gchar *wizard_get_default_domain_name(void)
        
        if (domain_name == NULL) {
                domain_name = g_strdup(get_domain_name());
-               if (strchr(domain_name, '.') != strrchr(domain_name, '.')
+               if (strchr(domain_name, '.') != NULL 
+               && strchr(domain_name, '.') != strrchr(domain_name, '.')
                && strlen(strchr(domain_name, '.')) > 6) {
                        gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
                        g_free(domain_name);