[Commits] [SCM] claws branch, master, updated. 3.10.0-61-g767368e
Colin
colin at claws-mail.org
Thu Jun 5 21:29:53 CEST 2014
The branch master of project "claws" (Claws Mail) has been updated
via 767368e8981d8c65d2bf0e800941c9f4713376f8 (commit)
via 168e74c7dfb9b4ccddb06b9b28a2a477c75647df (commit)
from a053d99543384865be56583236ef0c0def17a25e (commit)
- Log -----------------------------------------------------------------
commit 767368e8981d8c65d2bf0e800941c9f4713376f8
Author: Colin Leroy <colin at colino.net>
Date: Thu Jun 5 21:29:31 2014 +0200
More Coverity fixes
diff --git a/src/compose.c b/src/compose.c
index fa1e815..e1323f2 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -3207,7 +3207,7 @@ static gboolean is_subscription(const gchar *ml_post, const gchar *from)
*(strstr(left_from, "@")) = '\0';
}
- if (left_ml && left_from && right_ml && right_from
+ if (right_ml && right_from
&& !strncmp(left_from, left_ml, strlen(left_ml))
&& !strcmp(right_from, right_ml)) {
result = TRUE;
@@ -3575,7 +3575,6 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
gint len;
FILE *fp;
gboolean prev_autowrap;
- gboolean badtxt = FALSE;
struct stat file_stat;
int ret;
GString *file_contents = NULL;
@@ -3675,10 +3674,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
fclose(fp);
- if (badtxt)
- return COMPOSE_INSERT_INVALID_CHARACTER;
- else
- return COMPOSE_INSERT_SUCCESS;
+ return COMPOSE_INSERT_SUCCESS;
}
static gboolean compose_attach_append(Compose *compose, const gchar *file,
@@ -5757,8 +5753,11 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
(tmp, CS_INTERNAL, conv_get_locale_charset_str());
g_free(tmp);
- if (!chars) return -1;
-
+ if (!chars) {
+ fclose(fp);
+ claws_unlink(file);
+ return -1;
+ }
/* write body */
len = strlen(chars);
if (fwrite(chars, sizeof(gchar), len, fp) != len) {
@@ -6139,13 +6138,14 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
}
continue;
}
+ if (g_stat(ainfo->file, &statbuf) < 0)
+ return -1;
+
mimepart = procmime_mimeinfo_new();
mimepart->content = MIMECONTENT_FILE;
mimepart->data.filename = g_strdup(ainfo->file);
mimepart->tmp = FALSE; /* or we destroy our attachment */
mimepart->offset = 0;
-
- g_stat(ainfo->file, &statbuf);
mimepart->length = statbuf.st_size;
type = g_strdup(ainfo->content_type);
@@ -7375,8 +7375,9 @@ static void compose_dict_changed(void *data)
{
Compose *compose = (Compose *) data;
- if(compose->gtkaspell &&
- compose->gtkaspell->recheck_when_changing_dict == FALSE)
+ if(!compose->gtkaspell)
+ return;
+ if(compose->gtkaspell->recheck_when_changing_dict == FALSE)
return;
gtkaspell_highlight_all(compose->gtkaspell);
@@ -8924,7 +8925,7 @@ static void compose_attach_property(GtkAction *action, gpointer data)
gtk_widget_hide(attach_prop.window);
gtk_window_set_modal(GTK_WINDOW(attach_prop.window), FALSE);
- if (cancelled)
+ if (cancelled)
break;
entry_text = gtk_entry_get_text(GTK_ENTRY(attach_prop.mimetype_entry));
@@ -9530,7 +9531,7 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
/* Get ID of active account in the combo box */
menu = gtk_combo_box_get_model(optmenu);
- gtk_combo_box_get_active_iter(optmenu, &iter);
+ cm_return_if_fail(gtk_combo_box_get_active_iter(optmenu, &iter));
gtk_tree_model_get(menu, &iter, 1, &account_id, -1);
ac = account_find_from_id(account_id);
@@ -11192,10 +11193,7 @@ static void compose_insert_drag_received_cb (GtkWidget *widget,
g_list_free(list);
gtk_drag_finish(drag_context, TRUE, FALSE, time);
return;
- } else {
- return;
}
- gtk_drag_finish(drag_context, TRUE, FALSE, time);
}
static void compose_header_drag_received_cb (GtkWidget *widget,
diff --git a/src/edittags.c b/src/edittags.c
index dd74e13..a107c15 100644
--- a/src/edittags.c
+++ b/src/edittags.c
@@ -67,7 +67,7 @@ static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, g
return name2 == NULL ? 0:1;
if (name2 == NULL)
- return name1 == NULL ? 0:1;
+ return 1;
return g_utf8_collate(name1,name2);
}
diff --git a/src/filtering.c b/src/filtering.c
index 1d8126f..ff6eece 100644
--- a/src/filtering.c
+++ b/src/filtering.c
@@ -508,7 +508,10 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
abf = book->rawDataSource;
#endif
/* get the header */
- procheader_get_header_from_msginfo(info, buf, sizeof(buf), action->header);
+ if (procheader_get_header_from_msginfo(info, buf,
+ sizeof(buf), action->header) < 0)
+ return FALSE;
+
header = procheader_parse_header(buf);
/* add all addresses that are not already in */
diff --git a/src/folder.c b/src/folder.c
index 781b24c..2a8d862 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -2746,7 +2746,8 @@ void folder_item_write_cache(FolderItem *item)
filemode = prefs->folder_chmod;
if (filemode & S_IRGRP) filemode |= S_IWGRP;
if (filemode & S_IROTH) filemode |= S_IWOTH;
- chmod(cache_file, filemode);
+ if (cache_file != NULL)
+ chmod(cache_file, filemode);
}
} else {
item->cache_dirty = FALSE;
@@ -3605,13 +3606,12 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
}
}
}
-
- if (msginfo->planned_download
- == POP3_PARTIAL_DLOAD_DELE) {
+ if (newmsginfo != NULL
+ && msginfo->planned_download == POP3_PARTIAL_DLOAD_DELE) {
partial_mark_for_delete(newmsginfo);
}
- if (msginfo->planned_download
- == POP3_PARTIAL_DLOAD_DLOAD) {
+ if (newmsginfo != NULL
+ && msginfo->planned_download == POP3_PARTIAL_DLOAD_DLOAD) {
partial_mark_for_download(newmsginfo);
}
if (!MSG_IS_POSTFILTERED (msginfo->flags)) {
diff --git a/src/folderview.c b/src/folderview.c
index a52ce3f..e9b0943 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -2670,22 +2670,21 @@ static void folderview_drag_data_get(GtkWidget *widget,
FolderView *folderview)
{
FolderItem *item;
- GList *cur;
+ GList *sel;
gchar *source = NULL;
if (info == TARGET_DUMMY) {
- for (cur = GTK_CMCLIST(folderview->ctree)->selection;
- cur != NULL; cur = cur->next) {
- item = gtk_cmctree_node_get_row_data
- (GTK_CMCTREE(folderview->ctree),
- GTK_CMCTREE_NODE(cur->data));
- if (item) {
- source = g_strdup_printf ("FROM_OTHER_FOLDER%s", folder_item_get_identifier(item));
- gtk_selection_data_set(selection_data,
- gtk_selection_data_get_target(selection_data), 8,
- source, strlen(source));
- break;
- } else
- return;
+ sel = GTK_CMCLIST(folderview->ctree)->selection;
+ if (!sel)
+ return;
+
+ item = gtk_cmctree_node_get_row_data
+ (GTK_CMCTREE(folderview->ctree),
+ GTK_CMCTREE_NODE(sel->data));
+ if (item) {
+ source = g_strdup_printf ("FROM_OTHER_FOLDER%s", folder_item_get_identifier(item));
+ gtk_selection_data_set(selection_data,
+ gtk_selection_data_get_target(selection_data), 8,
+ source, strlen(source));
}
} else {
g_warning("unknown info %d\n", info);
diff --git a/src/grouplistdialog.c b/src/grouplistdialog.c
index 83b0ea7..21ee8d1 100644
--- a/src/grouplistdialog.c
+++ b/src/grouplistdialog.c
@@ -567,8 +567,9 @@ static gboolean button_press_cb(GtkCMCTree *ctree, GdkEventButton *button,
if (button->type != GDK_BUTTON_PRESS) return TRUE;
if (button->button != 1) return TRUE;
- gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree),
- button->x, button->y, &row, &col);
+ if (!gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree),
+ button->x, button->y, &row, &col))
+ return TRUE;
node = gtk_cmctree_node_nth(ctree, row);
if (!node) return TRUE;
diff --git a/src/gtk/gtkcmclist.c b/src/gtk/gtkcmclist.c
index fe0c071..3a28036 100644
--- a/src/gtk/gtkcmclist.c
+++ b/src/gtk/gtkcmclist.c
@@ -3727,6 +3727,7 @@ toggle_row (GtkCMCList *clist,
row, column, event);
return;
}
+ break;
case GTK_SELECTION_BROWSE:
g_signal_emit (G_OBJECT (clist), clist_signals[SELECT_ROW], 0,
row, column, event);
@@ -4641,7 +4642,6 @@ gtk_cmclist_realize (GtkWidget *widget)
#endif
/* main window */
- window = gtk_widget_get_window (widget);
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (window, clist);
@@ -5792,13 +5792,14 @@ draw_row (GtkCMCList *clist,
return;
widget = GTK_WIDGET (clist);
- style = clist_row->style ? clist_row->style : gtk_widget_get_style (widget);
/* if the function is passed the pointer to the row instead of null,
* it avoids this expensive lookup */
if (!clist_row)
clist_row = ROW_ELEMENT (clist, row)->data;
+ style = clist_row->style ? clist_row->style : gtk_widget_get_style (widget);
+
/* rectangle of the entire row */
row_rectangle.x = 0;
row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
@@ -6324,7 +6325,6 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
{
GtkCMCList *clist;
GtkContainer *container;
- GdkRectangle area;
gint i;
gint y = 0;
gint value;
@@ -6385,7 +6385,7 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
focus_row = clist->focus_row;
clist->focus_row = -1;
- draw_rows (clist, &area);
+ draw_rows (clist, NULL);
clist->focus_row = focus_row;
cairo_rectangle(cr, 0, y, clist->clist_window_width + 1,
@@ -7138,6 +7138,7 @@ scroll_vertical (GtkCMCList *clist,
default:
break;
}
+ /* fallback is intentional */
default:
if (old_focus_row != clist->focus_row &&
!(clist->selection_mode == GTK_SELECTION_MULTIPLE &&
@@ -7420,6 +7421,9 @@ gtk_cmclist_merge (GtkCMCList *clist,
c = &z;
+ if (!a && !b)
+ return NULL;
+
while (a || b)
{
if (a && !b)
@@ -7442,8 +7446,7 @@ gtk_cmclist_merge (GtkCMCList *clist,
{
cmp = clist->compare (clist, GTK_CMCLIST_ROW (a), GTK_CMCLIST_ROW (b));
if ((cmp >= 0 && clist->sort_type == GTK_SORT_DESCENDING) ||
- (cmp <= 0 && clist->sort_type == GTK_SORT_ASCENDING) ||
- (a && !b))
+ (cmp <= 0 && clist->sort_type == GTK_SORT_ASCENDING))
{
c->next = a;
a->prev = c;
diff --git a/src/gtk/gtkcmctree.c b/src/gtk/gtkcmctree.c
index ca65ca8..f8d9541 100644
--- a/src/gtk/gtkcmctree.c
+++ b/src/gtk/gtkcmctree.c
@@ -617,6 +617,12 @@ draw_row (GtkCMCList *clist,
cm_return_if_fail (clist != NULL);
widget = GTK_WIDGET (clist);
+
+ /* if the function is passed the pointer to the row instead of null,
+ * it avoids this expensive lookup */
+ if (!clist_row)
+ clist_row = (g_list_nth (clist->row_list, row))->data;
+
style = clist_row->style ? clist_row->style : gtk_widget_get_style (widget);
if (greybg.pixel == 0 &&
@@ -648,11 +654,6 @@ draw_row (GtkCMCList *clist,
ctree = GTK_CMCTREE (clist);
- /* if the function is passed the pointer to the row instead of null,
- * it avoids this expensive lookup */
- if (!clist_row)
- clist_row = (g_list_nth (clist->row_list, row))->data;
-
/* rectangle of the entire row */
row_rectangle.x = 0;
row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
diff --git a/src/gtk/gtkunit.c b/src/gtk/gtkunit.c
index 61272dd..5652610 100644
--- a/src/gtk/gtkunit.c
+++ b/src/gtk/gtkunit.c
@@ -569,16 +569,11 @@ gtk_param_unit_value_validate (GParamSpec *pspec,
GtkParamSpecUnit *uspec = GTK_PARAM_SPEC_UNIT (pspec);
gint oval = value->data[0].v_int;
- if (uspec->allow_percent && value->data[0].v_int == CM_UNIT_PERCENT)
- {
- value->data[0].v_int = value->data[0].v_int;
- }
- else
- {
+ if (uspec->allow_percent && value->data[0].v_int != CM_UNIT_PERCENT) {
value->data[0].v_int = CLAMP (value->data[0].v_int,
ispec->minimum,
gtk_unit_get_number_of_units () - 1);
- }
+ }
return value->data[0].v_int != oval;
}
diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c
index 08b0547..d547917 100644
--- a/src/gtk/gtkutils.c
+++ b/src/gtk/gtkutils.c
@@ -1099,7 +1099,8 @@ GtkWidget *xface_get_from_header(const gchar *o_xface)
static gchar *xpm_xface[XPM_XFACE_HEIGHT];
static gboolean xpm_xface_init = TRUE;
gchar xface[2048];
- strncpy(xface, o_xface, sizeof(xface));
+ strncpy(xface, o_xface, sizeof(xface) - 1);
+ xface[sizeof(xface) - 1] = '\0';
if (uncompface(xface) < 0) {
g_warning("uncompface failed\n");
@@ -1590,8 +1591,8 @@ gint gtkut_list_view_get_selected_row(GtkWidget *list_view)
for (row = 0; row < n_rows; row++) {
GtkTreeIter itern;
- gtk_tree_model_iter_nth_child(model, &itern, NULL, row);
- if (gtkut_tree_iter_comp(model, &iter, &itern))
+ if (gtk_tree_model_iter_nth_child(model, &itern, NULL, row)
+ && gtkut_tree_iter_comp(model, &iter, &itern))
return row;
}
@@ -2028,4 +2029,4 @@ gboolean auto_configure_service_sync(const gchar *service, const gchar *domain,
g_object_unref(resolver);
return result;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gtk/prefswindow.c b/src/gtk/prefswindow.c
index 57b1c57..0b407d3 100644
--- a/src/gtk/prefswindow.c
+++ b/src/gtk/prefswindow.c
@@ -316,7 +316,7 @@ static void prefswindow_build_page(PrefsWindow *prefswindow, PrefsPage *page)
}
}
-static void prefswindow_build_all_pages(PrefsWindow *prefswindow, GSList *prefs_pages)
+static GSList *prefswindow_build_all_pages(PrefsWindow *prefswindow, GSList *prefs_pages)
{
GSList *cur;
@@ -326,7 +326,7 @@ static void prefswindow_build_all_pages(PrefsWindow *prefswindow, GSList *prefs_
prefswindow_build_page(prefswindow, page);
}
- prefs_pages = g_slist_reverse(prefs_pages);
+ return g_slist_reverse(prefs_pages);
}
static void prefswindow_build_tree(GtkWidget *tree_view, GSList *prefs_pages,
@@ -346,7 +346,7 @@ static void prefswindow_build_tree(GtkWidget *tree_view, GSList *prefs_pages,
PrefsPage *page = (PrefsPage *)cur->data;
FindNodeByName find_name;
GtkTreeIter node, child;
- PrefsTreeNode *prefs_node;
+ PrefsTreeNode *prefs_node = NULL;
int i;
/* each page tree component string */
@@ -384,7 +384,10 @@ static void prefswindow_build_tree(GtkWidget *tree_view, GSList *prefs_pages,
}
/* right now we have a node and its prefs_node */
- prefs_node->page = page;
+ if (!prefs_node)
+ g_warning("no prefs_node :/");
+ else
+ prefs_node->page = page;
/* parents "inherit" the max weight of the children */
do {
@@ -416,7 +419,7 @@ static void prefswindow_build_tree(GtkWidget *tree_view, GSList *prefs_pages,
GTK_SORT_DESCENDING);
if (preload_pages)
- prefswindow_build_all_pages(prefswindow, prefs_pages);
+ prefs_pages = prefswindow_build_all_pages(prefswindow, prefs_pages);
/* select first one or its first child if necessary */
#ifndef GENERIC_UMPC
diff --git a/src/gtk/quicksearch.c b/src/gtk/quicksearch.c
index f10948b..d595c44 100644
--- a/src/gtk/quicksearch.c
+++ b/src/gtk/quicksearch.c
@@ -1014,7 +1014,7 @@ void quicksearch_pass_key(QuickSearch *quicksearch, guint val, GdkModifierType m
char *end = NULL;
char *new = NULL;
char key[7] = "";
- guint char_len = 0;
+ gint char_len = 0;
if (gtk_editable_get_selection_bounds(GTK_EDITABLE(entry), NULL, NULL)) {
/* remove selection */
commit 168e74c7dfb9b4ccddb06b9b28a2a477c75647df
Author: Colin Leroy <colin at colino.net>
Date: Thu Jun 5 20:41:04 2014 +0200
Coverity fixes
diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c
index be7dca5..87effcc 100644
--- a/src/etpan/imap-thread.c
+++ b/src/etpan/imap-thread.c
@@ -361,13 +361,17 @@ static struct etpan_thread * get_thread(Folder * folder)
struct etpan_thread * thread;
chashdatum key;
chashdatum value;
-
+ int r;
+
key.data = &folder;
key.len = sizeof(folder);
-
- chash_get(imap_hash, &key, &value);
+
+ r = chash_get(imap_hash, &key, &value);
+ if (r < 0)
+ return NULL;
+
thread = value.data;
-
+
return thread;
}
@@ -1499,15 +1503,24 @@ static struct mailimap_set_item *sc_mailimap_set_item_copy(struct mailimap_set_i
static struct mailimap_set *sc_mailimap_set_copy(struct mailimap_set *orig)
{
clist *list = orig ? orig->set_list : NULL;
- clist *newlist = clist_new();
+ clist *newlist;
clistiter *cur;
-
+
if (!orig)
return NULL;
- for (cur = clist_begin(list); cur; cur = clist_next(cur))
- clist_append(newlist,
+
+ newlist = clist_new();
+ if (!newlist)
+ return NULL;
+
+ for (cur = clist_begin(list); cur; cur = clist_next(cur)) {
+ if (clist_append(newlist,
sc_mailimap_set_item_copy(
- (struct mailimap_set_item *)clist_content(cur)));
+ (struct mailimap_set_item *)clist_content(cur))) != 0) {
+ clist_free(newlist);
+ return NULL;
+ }
+ }
return mailimap_set_new(newlist);
}
@@ -2695,11 +2708,11 @@ imap_fetch_result_to_envelop_list(clist * fetch_result,
carray ** p_env_list)
{
clistiter * cur;
- carray * env_list;
- env_list = carray_new(16);
-
if (fetch_result) {
+ carray * env_list;
+ env_list = carray_new(16);
+
for(cur = clist_begin(fetch_result) ; cur != NULL ;
cur = clist_next(cur)) {
struct mailimap_msg_att * msg_att;
@@ -2709,10 +2722,12 @@ imap_fetch_result_to_envelop_list(clist * fetch_result,
msg_att = clist_content(cur);
env_info = fetch_to_env_info(msg_att, &tags);
- if (!env_info)
+ if (!env_info
+ || carray_add(env_list, env_info, NULL) != 0
+ || carray_add(env_list, tags, NULL) != 0) {
+ carray_free(env_list);
return MAILIMAP_ERROR_MEMORY;
- carray_add(env_list, env_info, NULL);
- carray_add(env_list, tags, NULL);
+ }
}
* p_env_list = env_list;
} else {
@@ -2736,19 +2751,23 @@ static int imap_add_envelope_fetch_att(struct mailimap_fetch_type * fetch_type)
};
hdrlist = clist_new();
+ if (!hdrlist)
+ return MAIL_ERROR_MEMORY;
i = 0;
while (headers[i] != NULL) {
header = strdup(headers[i]);
- if (header == NULL || clist_append(hdrlist, header) != 0)
+ if (header == NULL || clist_append(hdrlist, header) != 0) {
+ clist_free(hdrlist);
return MAIL_ERROR_MEMORY;
+ }
++i;
}
-
+
imap_hdrlist = mailimap_header_list_new(hdrlist);
section = mailimap_section_new_header_fields(imap_hdrlist);
fetch_att = mailimap_fetch_att_new_body_peek_section(section);
mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
-
+
return MAIL_NO_ERROR;
}
diff --git a/src/etpan/nntp-thread.c b/src/etpan/nntp-thread.c
index b721e61..1161dd1 100644
--- a/src/etpan/nntp-thread.c
+++ b/src/etpan/nntp-thread.c
@@ -221,13 +221,17 @@ static struct etpan_thread * get_thread(Folder * folder)
struct etpan_thread * thread;
chashdatum key;
chashdatum value;
-
+ int r;
+
key.data = &folder;
key.len = sizeof(folder);
-
- chash_get(nntp_hash, &key, &value);
+
+ r = chash_get(nntp_hash, &key, &value);
+ if (r < 0)
+ return NULL;
+
thread = value.data;
-
+
return thread;
}
-----------------------------------------------------------------------
Summary of changes:
src/compose.c | 32 +++++++++++++--------------
src/edittags.c | 2 +-
src/etpan/imap-thread.c | 55 +++++++++++++++++++++++++++++++----------------
src/etpan/nntp-thread.c | 12 +++++++----
src/filtering.c | 5 ++++-
src/folder.c | 12 +++++------
src/folderview.c | 27 +++++++++++------------
src/grouplistdialog.c | 5 +++--
src/gtk/gtkcmclist.c | 15 +++++++------
src/gtk/gtkcmctree.c | 11 +++++-----
src/gtk/gtkunit.c | 9 ++------
src/gtk/gtkutils.c | 9 ++++----
src/gtk/prefswindow.c | 13 ++++++-----
src/gtk/quicksearch.c | 2 +-
14 files changed, 118 insertions(+), 91 deletions(-)
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list