[evolution/wip/webkit2] Fix some issues found by Coverity Scan, cppcheck and clang



commit 2f0ee6f4a9da5d2b4a95f5e4976e8729f1c2aefe
Author: Milan Crha <mcrha redhat com>
Date:   Mon May 16 21:53:16 2016 +0200

    Fix some issues found by Coverity Scan, cppcheck and clang

 addressbook/gui/widgets/ea-minicard.c             |    9 +------
 addressbook/gui/widgets/eab-gui-util.c            |    6 +++-
 calendar/alarm-notify/alarm-queue.c               |    3 +-
 calendar/gui/e-comp-editor-page-reminders.c       |    1 +
 calendar/gui/e-meeting-time-sel.c                 |   22 ++++++++------------
 calendar/gui/e-memo-table.c                       |    3 ++
 calendar/gui/e-week-view-main-item.c              |    2 +-
 e-util/e-html-editor-spell-check-dialog.c         |    6 +++-
 e-util/e-table-header-item.c                      |    4 ++-
 e-util/gal-a11y-e-table-item.c                    |    6 ++++-
 mail/mail-send-recv.c                             |    2 +-
 mail/message-list.c                               |    3 +-
 modules/bogofilter/evolution-bogofilter.c         |    2 +-
 plugins/attachment-reminder/attachment-reminder.c |    2 +-
 14 files changed, 39 insertions(+), 32 deletions(-)
---
diff --git a/addressbook/gui/widgets/ea-minicard.c b/addressbook/gui/widgets/ea-minicard.c
index 389e8e8..ad2e1f1 100644
--- a/addressbook/gui/widgets/ea-minicard.c
+++ b/addressbook/gui/widgets/ea-minicard.c
@@ -163,14 +163,9 @@ ea_minicard_get_name (AtkObject *accessible)
        g_string_append (new_str, string);
        g_free (string);
 
-       /* if there exist no enough space for remain info, return */
-       if (new_str->len >= BUFFERSIZE) {
-               strncpy (name, new_str->str, BUFFERSIZE);
-               name[BUFFERSIZE] = '\0';
-               return name;
-       }
+       strncpy (name, new_str->str, new_str->len + 1 >= BUFFERSIZE ? BUFFERSIZE : new_str->len + 1);
+       name[BUFFERSIZE] = '\0';
 
-       strcpy (name, new_str->str);
        g_string_free (new_str, TRUE);
 
        ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name);
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 7fa58d4..2114323 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -806,8 +806,10 @@ get_address_format (AddressFormat address_format,
        g_key_file_load_from_file (key_file, EVOLUTION_RULEDIR "/address_formats.dat", 0, &error);
        if (error != NULL) {
                g_warning ("%s: Failed to load address_formats.dat file: %s", G_STRFUNC, error->message);
-               *format = g_strdup (ADDRESS_DEFAULT_FORMAT);
-               *country_position = g_strdup (ADDRESS_DEFAULT_COUNTRY_POSITION);
+               if (format)
+                       *format = g_strdup (ADDRESS_DEFAULT_FORMAT);
+               if (country_position)
+                       *country_position = g_strdup (ADDRESS_DEFAULT_COUNTRY_POSITION);
                g_key_file_free (key_file);
                g_free (loc);
                g_error_free (error);
diff --git a/calendar/alarm-notify/alarm-queue.c b/calendar/alarm-notify/alarm-queue.c
index abe732d..5539c5c 100644
--- a/calendar/alarm-notify/alarm-queue.c
+++ b/calendar/alarm-notify/alarm-queue.c
@@ -731,7 +731,8 @@ remove_alarms (CompQueuedAlarms *cqa,
                l = l->next;
 
                alarm_remove (qa->alarm_id);
-               remove_queued_alarm (cqa, qa->alarm_id, free_object, FALSE);
+               if (remove_queued_alarm (cqa, qa->alarm_id, free_object, FALSE))
+                       break;
        }
 }
 
diff --git a/calendar/gui/e-comp-editor-page-reminders.c b/calendar/gui/e-comp-editor-page-reminders.c
index 8c13d54..9ceb4ec 100644
--- a/calendar/gui/e-comp-editor-page-reminders.c
+++ b/calendar/gui/e-comp-editor-page-reminders.c
@@ -632,6 +632,7 @@ ecep_reminders_widgets_to_selected (ECompEditorPageReminders *page_reminders)
                        g_return_if_reached ();
                }
        } else {
+               memset (&repeat, 0, sizeof (repeat));
                repeat.repetitions = 0;
        }
 
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 7851c72..bd8a4bc 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -2384,6 +2384,15 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
                        longest_weekday = day;
                        longest_weekday_width = width;
                }
+
+               /* Now try it with abbreviated weekday names. */
+               name = e_get_weekday_name (day, TRUE);
+               pango_layout_set_text (layout, name, -1);
+               pango_layout_get_pixel_size (layout, &width, NULL);
+               if (width > longest_weekday_width) {
+                       longest_weekday = day;
+                       longest_weekday_width = width;
+               }
        }
 
        /* Now find the biggest month name. */
@@ -2399,19 +2408,6 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
                }
        }
 
-       /* Now try it with abbreviated weekday names. */
-       longest_weekday_width = 0;
-       longest_weekday = G_DATE_MONDAY;
-       for (day = G_DATE_MONDAY; day <= G_DATE_SUNDAY; day++) {
-               name = e_get_weekday_name (day, TRUE);
-               pango_layout_set_text (layout, name, -1);
-               pango_layout_get_pixel_size (layout, &width, NULL);
-               if (width > longest_weekday_width) {
-                       longest_weekday = day;
-                       longest_weekday_width = width;
-               }
-       }
-
        g_date_set_dmy (
                &date, days[longest_month - 1] + longest_weekday,
                longest_month, 2000);
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index 8581448..1a80643 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -426,6 +426,9 @@ memo_table_query_tooltip (GtkWidget *widget,
        if (esm && esm->sorter && e_sorter_needs_sorting (esm->sorter))
                row = e_sorter_sorted_to_model (esm->sorter, row);
 
+       if (row < 0)
+               return FALSE;
+
        model = e_memo_table_get_model (memo_table);
        comp_data = e_cal_model_get_component_at (model, row);
        if (!comp_data || !comp_data->icalcomp)
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index 69caa62..cf69529 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -159,7 +159,7 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
                                cr, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]);
                } else {
                        gdk_cairo_set_source_color (
-                               cr, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]);
+                               cr, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED_UNFOCUSSED]);
                }
 
                if (multi_week_view) {
diff --git a/e-util/e-html-editor-spell-check-dialog.c b/e-util/e-html-editor-spell-check-dialog.c
index 6d22c98..510caea 100644
--- a/e-util/e-html-editor-spell-check-dialog.c
+++ b/e-util/e-html-editor-spell-check-dialog.c
@@ -202,7 +202,8 @@ html_editor_spell_check_dialog_replace (EHTMLEditorSpellCheckDialog *dialog)
 
        selection = gtk_tree_view_get_selection (
                GTK_TREE_VIEW (dialog->priv->tree_view));
-       gtk_tree_selection_get_selected (selection, &model, &iter);
+       if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+               return;
        gtk_tree_model_get (model, &iter, 0, &replacement, -1);
 
        e_content_editor_insert_content (
@@ -228,7 +229,8 @@ html_editor_spell_check_dialog_replace_all (EHTMLEditorSpellCheckDialog *dialog)
 
        selection = gtk_tree_view_get_selection (
                GTK_TREE_VIEW (dialog->priv->tree_view));
-       gtk_tree_selection_get_selected (selection, &model, &iter);
+       if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+               return;
        gtk_tree_model_get (model, &iter, 0, &replacement, -1);
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
diff --git a/e-util/e-table-header-item.c b/e-util/e-table-header-item.c
index dec782f..8aaac68 100644
--- a/e-util/e-table-header-item.c
+++ b/e-util/e-table-header-item.c
@@ -2028,8 +2028,10 @@ ethi_event (GnomeCanvasItem *item,
                                ethi->click_x = event_x_win;
                                ethi->click_y = event_y_win;
                                ethi->maybe_drag = TRUE;
+                               col = -1;
                                is_pointer_on_division (ethi, x, &start, &col);
-                               ethi->selected_col = col;
+                               if (col != -1)
+                                       ethi->selected_col = col;
                                if (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas)))
                                        e_canvas_item_grab_focus (item, TRUE);
                        } else if (event_button == 3) {
diff --git a/e-util/gal-a11y-e-table-item.c b/e-util/gal-a11y-e-table-item.c
index c94b2cb..6ddcb3e 100644
--- a/e-util/gal-a11y-e-table-item.c
+++ b/e-util/gal-a11y-e-table-item.c
@@ -945,8 +945,12 @@ eti_header_structure_changed (ETableHeader *eth,
        }
 
        /* If nothing interesting just return. */
-       if (!reorder_found && !added_found && !removed_found)
+       if (!reorder_found && !added_found && !removed_found) {
+               g_free (state);
+               g_free (reorder);
+               g_free (prev_state);
                return;
+       }
 
        /* Emit signals */
        if (reorder_found)
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 5bbcfc5..279a63b 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -1292,7 +1292,7 @@ refresh_folders_exec (struct _refresh_folders_msg *m,
                                g_clear_error (&local_error);
                                break;
                        } else if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
-                               CamelStore *store = m->store;
+                               CamelStore *store;
                                const gchar *full_name;
 
                                if (folder) {
diff --git a/mail/message-list.c b/mail/message-list.c
index 21a1dde..9d8c404 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -6266,7 +6266,8 @@ mail_regen_list (MessageList *message_list,
                        tmp_search_copy = g_strdup (old_regen_data->search);
                        search = tmp_search_copy;
                } else {
-                       search = message_list->search;
+                       tmp_search_copy = g_strdup (message_list->search);
+                       search = tmp_search_copy;
                }
 
                if (old_regen_data)
diff --git a/modules/bogofilter/evolution-bogofilter.c b/modules/bogofilter/evolution-bogofilter.c
index a57fba3..50e81e2 100644
--- a/modules/bogofilter/evolution-bogofilter.c
+++ b/modules/bogofilter/evolution-bogofilter.c
@@ -400,7 +400,7 @@ bogofilter_classify (CamelJunkFilter *junk_filter,
 {
        EBogofilter *extension = E_BOGOFILTER (junk_filter);
        static gboolean wordlist_initialized = FALSE;
-       CamelJunkStatus status;
+       CamelJunkStatus status = CAMEL_JUNK_STATUS_ERROR;
        gint exit_code;
 
        const gchar *argv[] = {
diff --git a/plugins/attachment-reminder/attachment-reminder.c 
b/plugins/attachment-reminder/attachment-reminder.c
index 0031c63..aec294d 100644
--- a/plugins/attachment-reminder/attachment-reminder.c
+++ b/plugins/attachment-reminder/attachment-reminder.c
@@ -191,7 +191,7 @@ check_for_attachment_clues (GByteArray *msg_text)
                        to = word->len;
                        g_string_append (word, clue);
 
-                       for (jj = word->len - 1; jj <= to; jj--) {
+                       for (jj = word->len - 1; jj >= to; jj--) {
                                if (word->str[jj] == '\\' || word->str[jj] == '\"')
                                        g_string_insert_c (word, jj, '\\');
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]