[evolution/wip/mcrha/eds-libical-glib] Address some issues reported by static analyzers (Coverity Scan, clang)



commit 7cb992297f4a768b8d7084ebe7b068f780e58c70
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 25 15:12:20 2019 +0200

    Address some issues reported by static analyzers (Coverity Scan, clang)

 src/addressbook/gui/widgets/eab-contact-display.c  |   2 +-
 src/calendar/gui/comp-util.c                       |   7 +-
 src/calendar/gui/e-cal-component-preview.c         |   3 +-
 src/calendar/gui/e-cal-dialogs.c                   |   2 +-
 src/calendar/gui/e-calendar-view.c                 |   8 +-
 src/calendar/gui/e-day-view.c                      |   3 -
 src/calendar/gui/e-meeting-store.c                 |   1 -
 src/calendar/gui/e-memo-table.c                    |  12 +-
 src/calendar/gui/e-select-names-editable.c         |   1 +
 src/calendar/gui/e-send-options-utils.c            |   5 -
 src/calendar/gui/e-task-table.c                    |  12 +-
 src/calendar/gui/e-week-view.c                     |   2 -
 src/calendar/gui/print.c                           |   4 +
 src/e-util/e-alert-bar.c                           |   2 -
 src/e-util/e-html-editor-find-dialog.c             |   6 -
 src/e-util/e-name-selector-dialog.c                |  48 ++---
 src/e-util/e-name-selector-model.c                 |  10 +-
 src/e-util/e-tree-table-adapter.c                  |   4 +-
 src/e-util/e-unicode.c                             |   3 +-
 src/e-util/test-html-editor-units-utils.c          |   4 +-
 src/em-format/e-mail-formatter-message-rfc822.c    |   4 +
 .../e-mail-formatter-quote-message-rfc822.c        |   2 +
 src/em-format/e-mail-stripsig-filter.c             |   2 +-
 src/mail/e-mail-folder-sort-order-dialog.c         |   2 -
 src/mail/e-mail-notes.c                            |   2 -
 src/mail/e-mail-request.c                          |   4 +-
 src/mail/e-mail-templates-store.c                  |   2 +-
 src/mail/em-subscription-editor.c                  |   1 -
 src/modules/calendar/e-cal-shell-content.c         |   6 +-
 src/modules/calendar/e-cal-shell-view.c            |   6 -
 src/modules/mail/e-mail-shell-view-private.c       |   2 -
 .../e-mail-formatter-text-highlight.c              |  11 +-
 .../web-extension/e-editor-dom-functions.c         | 196 +++++++++++----------
 src/plugins/pst-import/pst-importer.c              |   3 +-
 34 files changed, 188 insertions(+), 194 deletions(-)
---
diff --git a/src/addressbook/gui/widgets/eab-contact-display.c 
b/src/addressbook/gui/widgets/eab-contact-display.c
index ecb217ffe7..ada3a2fa73 100644
--- a/src/addressbook/gui/widgets/eab-contact-display.c
+++ b/src/addressbook/gui/widgets/eab-contact-display.c
@@ -368,7 +368,7 @@ contact_display_link_clicked (EWebView *web_view,
        }
 
        length = strlen ("open-map:");
-       if (g_str_has_prefix (uri, "open-map:")) {
+       if (g_ascii_strncasecmp (uri, "open-map:", length)) {
                SoupURI *suri;
 
                suri = soup_uri_new (uri);
diff --git a/src/calendar/gui/comp-util.c b/src/calendar/gui/comp-util.c
index 064e44aa71..dbda0f8c44 100644
--- a/src/calendar/gui/comp-util.c
+++ b/src/calendar/gui/comp-util.c
@@ -670,8 +670,8 @@ datetime_to_zone (ECalClient *client,
        if (!from) {
                GError *error = NULL;
 
-               e_cal_client_get_timezone_sync (
-                       client, e_cal_component_datetime_get_tzid (date), &from, NULL, &error);
+               if (!e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (date), &from, 
NULL, &error))
+                       from = NULL;
 
                if (error != NULL) {
                        g_warning (
@@ -685,7 +685,8 @@ datetime_to_zone (ECalClient *client,
        to = i_cal_timezone_get_builtin_timezone_from_tzid (tzid);
        if (!to) {
                /* do not check failure here, maybe the zone is not available there */
-               e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL);
+               if (!e_cal_client_get_timezone_sync (client, tzid, &to, NULL, NULL))
+                       to = NULL;
        }
 
        i_cal_timezone_convert_time (e_cal_component_datetime_get_value (date), from, to);
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index ee7d890d46..17270d55a0 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -166,7 +166,8 @@ timet_to_str_with_zone (ECalComponentDateTime *dt,
        itt = e_cal_component_datetime_get_value (dt);
 
        if (e_cal_component_datetime_get_tzid (dt)) {
-               e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (dt), &zone, NULL, 
NULL);
+               if (!e_cal_client_get_timezone_sync (client, e_cal_component_datetime_get_tzid (dt), &zone, 
NULL, NULL))
+                       zone = NULL;
        } else if (i_cal_time_is_utc (itt)) {
                zone = i_cal_timezone_get_utc_timezone ();
        }
diff --git a/src/calendar/gui/e-cal-dialogs.c b/src/calendar/gui/e-cal-dialogs.c
index 933d6aa4ea..eaeef3a7c2 100644
--- a/src/calendar/gui/e-cal-dialogs.c
+++ b/src/calendar/gui/e-cal-dialogs.c
@@ -660,7 +660,7 @@ get_current_time (ECalendarItem *calitem,
 {
        ICalTimezone *zone;
        ICalTime *tt;
-       struct tm tmp_tm = { 0 };
+       struct tm tmp_tm;
 
        /* Get the current timezone. */
        zone = calendar_config_get_icaltimezone ();
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index 01aadaa9e6..31664636bd 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -1384,7 +1384,7 @@ e_calendar_view_get_paste_target_list (ECalendarView *cal_view)
 gint
 e_calendar_view_get_time_divisions (ECalendarView *cal_view)
 {
-       g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), 0);
+       g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), 30);
 
        return cal_view->priv->time_divisions;
 }
@@ -1395,6 +1395,10 @@ e_calendar_view_set_time_divisions (ECalendarView *cal_view,
 {
        g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
 
+       /* To avoid division-by-zero and negative values on places where this is used */
+       if (time_divisions <= 0)
+               time_divisions = 30;
+
        if (cal_view->priv->time_divisions == time_divisions)
                return;
 
@@ -2134,7 +2138,7 @@ e_calendar_view_dup_component_summary (ICalComponent *icomp)
                                   The string is used for Birthday & Anniversary events where the first year 
is
                                   know, constructing a summary which also shows how many years the birthday 
or
                                   anniversary is for. Example: "Birthday: John Doe (13)" */
-                               summary = g_strdup_printf (C_("BirthdaySummary", "%s (%d)"), summary ? 
summary : "", i_cal_time_get_year (dtstart) - since_year);
+                               res = g_strdup_printf (C_("BirthdaySummary", "%s (%d)"), summary ? summary : 
"", i_cal_time_get_year (dtstart) - since_year);
                        }
 
                        g_clear_object (&dtstart);
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index dd24033191..e0e9ed8797 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -3197,9 +3197,6 @@ e_day_view_remove_event_cb (EDayView *day_view,
                                        EDayViewEvent, event_num);
        }
 
-       if (!event)
-               return TRUE;
-
        /* If we were editing this event, set editing_event_day to -1 so
         * on_editing_stopped doesn't try to update the event. */
        if (day_view->editing_event_num == event_num && day_view->editing_event_day == day) {
diff --git a/src/calendar/gui/e-meeting-store.c b/src/calendar/gui/e-meeting-store.c
index 815f55719a..0df2eb15e1 100644
--- a/src/calendar/gui/e-meeting-store.c
+++ b/src/calendar/gui/e-meeting-store.c
@@ -2051,7 +2051,6 @@ soup_authenticate (SoupSession *session,
 
                if (password) {
                        soup_auth_authenticate (auth, suri->user, password);
-                       tried = TRUE;
 
                        memset (password, 0, strlen (password));
                        g_free (password);
diff --git a/src/calendar/gui/e-memo-table.c b/src/calendar/gui/e-memo-table.c
index f42a824eac..133659437b 100644
--- a/src/calendar/gui/e-memo-table.c
+++ b/src/calendar/gui/e-memo-table.c
@@ -512,9 +512,10 @@ memo_table_query_tooltip (GtkWidget *widget,
                zone = i_cal_component_get_timezone (
                        e_cal_component_get_icalcomponent (new_comp),
                        e_cal_component_datetime_get_tzid (dtstart));
-               if (!zone)
-                       e_cal_client_get_timezone_sync (
-                               comp_data->client, e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, 
NULL);
+               if (!zone) {
+                       if (!e_cal_client_get_timezone_sync (comp_data->client, 
e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, NULL))
+                               zone = NULL;
+               }
                if (!zone)
                        zone = default_zone;
        } else {
@@ -931,7 +932,10 @@ get_selected_comp (EMemoTable *memo_table)
        row = -1;
        e_table_selected_row_foreach (
                E_TABLE (memo_table), get_selected_row_cb, &row);
-       g_return_val_if_fail (row != -1, NULL);
+       if (row < 0) {
+               g_warn_if_reached ();
+               return NULL;
+       }
 
        return e_cal_model_get_component_at (model, row);
 }
diff --git a/src/calendar/gui/e-select-names-editable.c b/src/calendar/gui/e-select-names-editable.c
index d57e7ce93b..e9152263ed 100644
--- a/src/calendar/gui/e-select-names-editable.c
+++ b/src/calendar/gui/e-select-names-editable.c
@@ -262,4 +262,5 @@ e_select_names_editable_set_address (ESelectNamesEditable *esne,
                        destination_store, destination);
 
        g_object_unref (destination);
+       g_list_free (list);
 }
diff --git a/src/calendar/gui/e-send-options-utils.c b/src/calendar/gui/e-send-options-utils.c
index bb3cc5157f..cf575ae474 100644
--- a/src/calendar/gui/e-send-options-utils.c
+++ b/src/calendar/gui/e-send-options-utils.c
@@ -188,7 +188,6 @@ e_send_options_utils_fill_component (ESendOptionsDialog *sod,
                                     ECalComponent *comp,
                                     ICalTimezone *zone)
 {
-       gint ii;
        ICalProperty *prop;
        ICalComponent *icomp;
        ESendOptionsGeneral *gopts;
@@ -197,10 +196,6 @@ e_send_options_utils_fill_component (ESendOptionsDialog *sod,
        gopts = sod->data->gopts;
        sopts = sod->data->sopts;
 
-       ii = e_cal_component_get_sequence (comp);
-       if (ii < 1)
-               ii = 1;
-
        icomp = e_cal_component_get_icalcomponent (comp);
 
        if (e_send_options_get_need_general_options (sod)) {
diff --git a/src/calendar/gui/e-task-table.c b/src/calendar/gui/e-task-table.c
index b63b2b03cb..50f344ef7c 100644
--- a/src/calendar/gui/e-task-table.c
+++ b/src/calendar/gui/e-task-table.c
@@ -850,9 +850,10 @@ task_table_query_tooltip (GtkWidget *widget,
                zone = i_cal_component_get_timezone (
                        e_cal_component_get_icalcomponent (new_comp),
                        e_cal_component_datetime_get_tzid (dtstart));
-               if (!zone)
-                       e_cal_client_get_timezone_sync (
-                               comp_data->client, e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, 
NULL);
+               if (!zone) {
+                       if (!e_cal_client_get_timezone_sync (comp_data->client, 
e_cal_component_datetime_get_tzid (dtstart), &zone, NULL, NULL))
+                               zone = NULL;
+               }
                if (!zone)
                        zone = default_zone;
        } else {
@@ -1305,7 +1306,10 @@ get_selected_comp (ETaskTable *task_table)
        row = -1;
        e_table_selected_row_foreach (
                E_TABLE (task_table), get_selected_row_cb, &row);
-       g_return_val_if_fail (row != -1, NULL);
+       if (row < 0) {
+               g_warn_if_reached ();
+               return NULL;
+       }
 
        return e_cal_model_get_component_at (model, row);
 }
diff --git a/src/calendar/gui/e-week-view.c b/src/calendar/gui/e-week-view.c
index 37c19ed96d..cfd3be0f5b 100644
--- a/src/calendar/gui/e-week-view.c
+++ b/src/calendar/gui/e-week-view.c
@@ -2753,8 +2753,6 @@ e_week_view_remove_event_cb (EWeekView *week_view,
                return TRUE;
 
        event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
-       if (!event)
-               return TRUE;
 
        /* If we were editing this event, set editing_event_num to -1 so
         * on_editing_stopped doesn't try to update the event. */
diff --git a/src/calendar/gui/print.c b/src/calendar/gui/print.c
index 1935bab32b..20ff86754e 100644
--- a/src/calendar/gui/print.c
+++ b/src/calendar/gui/print.c
@@ -1725,6 +1725,8 @@ print_day_details (GtkPrintContext *context,
 
        /* use font like with 30 minutes time division */
        rows_with_30_mins = (pdi.end_hour - pdi.start_hour) * (60 / 30);
+       if (rows_with_30_mins <= 0)
+               rows_with_30_mins = 2;
 
        pango_font_description_free (font);
 
@@ -2890,6 +2892,8 @@ print_work_week_day_details (GtkPrintContext *context,
 
        /* use font like with 30 minutes time division */
        rows_with_30_mins = (pdi.end_hour - pdi.start_hour) * (60 / 30);
+       if (rows_with_30_mins <= 0)
+               rows_with_30_mins = 2;
 
        pango_font_description_free (font);
 
diff --git a/src/e-util/e-alert-bar.c b/src/e-util/e-alert-bar.c
index 51346dd354..5f1a8f82f5 100644
--- a/src/e-util/e-alert-bar.c
+++ b/src/e-util/e-alert-bar.c
@@ -305,8 +305,6 @@ alert_bar_constructed (GObject *object)
        priv->secondary_label = widget;
        gtk_widget_show (widget);
 
-       container = action_area;
-
        /* Disable animation of the revealer, until GtkInfoBar's bug #710888 is fixed */
        revealer = gtk_widget_get_template_child (GTK_WIDGET (object), GTK_TYPE_INFO_BAR, "revealer");
        if (revealer) {
diff --git a/src/e-util/e-html-editor-find-dialog.c b/src/e-util/e-html-editor-find-dialog.c
index b8a3d97e52..49def0b946 100644
--- a/src/e-util/e-html-editor-find-dialog.c
+++ b/src/e-util/e-html-editor-find-dialog.c
@@ -240,12 +240,6 @@ e_html_editor_find_dialog_init (EHTMLEditorFindDialog *dialog)
        gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
        dialog->priv->result_label = widget;
 
-       widget = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
-       gtk_box_set_spacing (GTK_BOX (widget), 5);
-       gtk_button_box_set_layout (GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END);
-       gtk_box_pack_end (box, widget, TRUE, TRUE, 0);
-       box = GTK_BOX (widget);
-
        box = e_html_editor_dialog_get_button_box (E_HTML_EDITOR_DIALOG (dialog));
        widget = e_dialog_button_new_with_icon ("edit-find", _("_Find"));
        gtk_box_pack_start (box, widget, FALSE, FALSE, 5);
diff --git a/src/e-util/e-name-selector-dialog.c b/src/e-util/e-name-selector-dialog.c
index 30e39fa4ba..8995fe28e1 100644
--- a/src/e-util/e-name-selector-dialog.c
+++ b/src/e-util/e-name-selector-dialog.c
@@ -1146,7 +1146,10 @@ model_section_removed (ENameSelectorDialog *name_selector_dialog,
        gint section_index;
 
        section_index = find_section_by_name (name_selector_dialog, name);
-       g_return_if_fail (section_index >= 0);
+       if (section_index < 0) {
+               g_warn_if_reached ();
+               return;
+       }
 
        free_section (name_selector_dialog, section_index);
        g_array_remove_index (
@@ -1272,13 +1275,9 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
 {
        GCancellable *cancellable;
        ESource *source;
-       gpointer parent;
 
        source = e_source_combo_box_ref_active (E_SOURCE_COMBO_BOX (combo_box));
 
-       parent = gtk_widget_get_toplevel (GTK_WIDGET (name_selector_dialog));
-       parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
        /* Remove any previous books being shown or loaded */
        remove_books (name_selector_dialog);
 
@@ -1495,6 +1494,7 @@ remove_selection (ENameSelectorDialog *name_selector_dialog,
        Section           *section;
        GtkTreeSelection  *selection;
        GList             *rows, *l;
+       gboolean res = TRUE;
 
        section_index = find_section_by_tree_view (
                name_selector_dialog, tree_view);
@@ -1525,21 +1525,26 @@ remove_selection (ENameSelectorDialog *name_selector_dialog,
                GtkTreeIter iter;
                GtkTreePath *path = l->data;
 
-               if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (destination_store), &iter, path))
-                       g_return_val_if_reached (FALSE);
-
-               gtk_tree_path_free (path);
+               if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (destination_store), &iter, path)) {
+                       g_warn_if_reached ();
+                       res = FALSE;
+                       break;
+               }
 
-               destination = e_destination_store_get_destination (
-                       destination_store, &iter);
-               g_return_val_if_fail (destination, FALSE);
+               destination = e_destination_store_get_destination (destination_store, &iter);
+               if (!destination) {
+                       g_warn_if_reached ();
+                       res = FALSE;
+                       break;
+               }
 
                e_destination_store_remove_destination (
                        destination_store, destination);
        }
-       g_list_free (rows);
 
-       return TRUE;
+       g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
+
+       return res;
 }
 
 static void
@@ -1616,21 +1621,15 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog,
                GtkTreeIter iter;
                GtkTreePath *path = l->data;
 
-               if (!gtk_tree_model_get_iter (
-                       GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort),
-                       &iter, path)) {
-                       gtk_tree_path_free (path);
-                       return;
-               }
+               if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort), 
&iter, path))
+                       break;
 
-               gtk_tree_path_free (path);
                sort_iter_to_contact_store_iter (name_selector_dialog, &iter, &email_n);
 
                contact = e_contact_store_get_contact (contact_store, &iter);
                if (!contact) {
                        g_warning ("ENameSelectorDialog could not get selected contact!");
-                       g_list_free (rows);
-                       return;
+                       break;
                }
 
                add_destination (
@@ -1638,7 +1637,8 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog,
                        destination_store, contact, email_n,
                        e_contact_store_get_client (contact_store, &iter));
        }
-       g_list_free (rows);
+
+       g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
 }
 
 /* --------------------- *
diff --git a/src/e-util/e-name-selector-model.c b/src/e-util/e-name-selector-model.c
index 5443b66e89..815e8703d3 100644
--- a/src/e-util/e-name-selector-model.c
+++ b/src/e-util/e-name-selector-model.c
@@ -623,10 +623,12 @@ e_name_selector_model_get_contact_emails_without_used (ENameSelectorModel *name_
                                } else {
                                        GList *nth = g_list_nth (email_list, email_num);
 
-                                       g_return_val_if_fail (nth != NULL, NULL);
-
-                                       g_free (nth->data);
-                                       nth->data = NULL;
+                                       if (nth) {
+                                               g_free (nth->data);
+                                               nth->data = NULL;
+                                       } else {
+                                               g_warn_if_reached ();
+                                       }
                                }
                        }
                }
diff --git a/src/e-util/e-tree-table-adapter.c b/src/e-util/e-tree-table-adapter.c
index 044ed42093..b64f73c322 100644
--- a/src/e-util/e-tree-table-adapter.c
+++ b/src/e-util/e-tree-table-adapter.c
@@ -1419,10 +1419,8 @@ e_tree_table_adapter_load_expanded_state_xml (ETreeTableAdapter *etta,
 
        /* Incase the default is changed, lets forget the changes and stick to default */
 
-       if (file_default != model_default) {
-               xmlFreeDoc (doc);
+       if (file_default != model_default)
                return;
-       }
 
        for (child = root->xmlChildrenNode; child; child = child->next) {
                gchar *id;
diff --git a/src/e-util/e-unicode.c b/src/e-util/e-unicode.c
index d386b37f64..513cdcf505 100644
--- a/src/e-util/e-unicode.c
+++ b/src/e-util/e-unicode.c
@@ -90,7 +90,8 @@ e_utf8_from_iconv_string_sized (iconv_t ic,
                for (i = 0; i < (bytes); i++) {
                        ob += e_unichar_to_utf8 (ib[i], ob);
                }
-               *ob = '\0';
+               if (ob)
+                       *ob = '\0';
                return new;
        }
 
diff --git a/src/e-util/test-html-editor-units-utils.c b/src/e-util/test-html-editor-units-utils.c
index bf854a9ce3..daedae625f 100644
--- a/src/e-util/test-html-editor-units-utils.c
+++ b/src/e-util/test-html-editor-units-utils.c
@@ -1101,9 +1101,9 @@ test_utils_get_content_editor (TestFixture *fixture)
 gchar *
 test_utils_get_base64_data_for_image (const gchar *path)
 {
-       gchar *image_data;
+       gchar *image_data = NULL;
        gchar *image_data_base64;
-       gsize image_data_length;
+       gsize image_data_length = 0;
        gboolean success;
        GError *error = NULL;
 
diff --git a/src/em-format/e-mail-formatter-message-rfc822.c b/src/em-format/e-mail-formatter-message-rfc822.c
index 5df3a2ea06..dc97185db1 100644
--- a/src/em-format/e-mail-formatter-message-rfc822.c
+++ b/src/em-format/e-mail-formatter-message-rfc822.c
@@ -96,6 +96,8 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
                                while (link != NULL) {
                                        p = link->data;
 
+                                       p_id = e_mail_part_get_id (p);
+
                                        if (g_strcmp0 (p_id, sub_end) == 0)
                                                break;
 
@@ -164,6 +166,8 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension,
                                while (link != NULL) {
                                        p = link->data;
 
+                                       p_id = e_mail_part_get_id (p);
+
                                        if (g_strcmp0 (p_id, sub_end) == 0)
                                                break;
 
diff --git a/src/em-format/e-mail-formatter-quote-message-rfc822.c 
b/src/em-format/e-mail-formatter-quote-message-rfc822.c
index 3dc59bacff..d660958832 100644
--- a/src/em-format/e-mail-formatter-quote-message-rfc822.c
+++ b/src/em-format/e-mail-formatter-quote-message-rfc822.c
@@ -105,6 +105,8 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension,
                        while (link != NULL) {
                                p = link->data;
 
+                               p_id = e_mail_part_get_id (p);
+
                                if (g_strcmp0 (p_id, sub_end) == 0)
                                        break;
 
diff --git a/src/em-format/e-mail-stripsig-filter.c b/src/em-format/e-mail-stripsig-filter.c
index fb1f1d38f1..be2d29546d 100644
--- a/src/em-format/e-mail-stripsig-filter.c
+++ b/src/em-format/e-mail-stripsig-filter.c
@@ -87,7 +87,7 @@ strip_signature (CamelMimeFilter *filter,
                }
        }
 
-       while (inptr < inend) {
+       while (inptr && inptr < inend) {
                if ((inend - inptr) >= 4 && !strncmp (inptr, "-- \n", 4)) {
                        start = inptr;
                        inptr += 4;
diff --git a/src/mail/e-mail-folder-sort-order-dialog.c b/src/mail/e-mail-folder-sort-order-dialog.c
index 0b095f98ca..24d3958a58 100644
--- a/src/mail/e-mail-folder-sort-order-dialog.c
+++ b/src/mail/e-mail-folder-sort-order-dialog.c
@@ -67,8 +67,6 @@ sort_order_dialog_selection_changed_cb (GtkTreeSelection *selection,
              gtk_tree_model_iter_children (model, &iter, &parent);
 
        if (can) {
-               can = FALSE;
-
                do {
                        guint sort_order = 0;
 
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index db50e57bfd..090198a446 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -1009,8 +1009,6 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
 
        content = widget;
 
-       widget = GTK_WIDGET (html_editor);
-
        notes_editor->editor = html_editor;
        cnt_editor = e_html_editor_get_content_editor (notes_editor->editor);
        ui_manager = e_html_editor_get_ui_manager (notes_editor->editor);
diff --git a/src/mail/e-mail-request.c b/src/mail/e-mail-request.c
index 67fd699bb4..a7740b9179 100644
--- a/src/mail/e-mail-request.c
+++ b/src/mail/e-mail-request.c
@@ -197,7 +197,7 @@ mail_request_process_mail_sync (EContentRequest *request,
                                                        -1);
 
                                                if (icon) {
-                                                       const gchar *size = uri_query ? g_hash_table_lookup 
(uri_query, "size") : NULL;
+                                                       const gchar *size = g_hash_table_lookup (uri_query, 
"size");
                                                        if (!size)
                                                                size = "16";
 
@@ -236,7 +236,7 @@ mail_request_process_mail_sync (EContentRequest *request,
                }
                g_free (part_id);
 
-               mime_type = uri_query ? g_hash_table_lookup (uri_query, "mime_type") : NULL;
+               mime_type = g_hash_table_lookup (uri_query, "mime_type");
 
                if (context.mode == E_MAIL_FORMATTER_MODE_SOURCE)
                        mime_type = "application/vnd.evolution.source";
diff --git a/src/mail/e-mail-templates-store.c b/src/mail/e-mail-templates-store.c
index ba830eecd0..57fdea7c33 100644
--- a/src/mail/e-mail-templates-store.c
+++ b/src/mail/e-mail-templates-store.c
@@ -2373,7 +2373,7 @@ e_mail_templates_store_build_model (EMailTemplatesStore *templates_store,
        GSList *link;
        gint multiple_accounts = 0;
        gboolean found_first_message = FALSE;
-       GtkTreeIter found_first_iter;
+       GtkTreeIter found_first_iter = { 0, };
 
        g_return_val_if_fail (E_IS_MAIL_TEMPLATES_STORE (templates_store), NULL);
 
diff --git a/src/mail/em-subscription-editor.c b/src/mail/em-subscription-editor.c
index 2e2cb95c4c..8cb51a82e2 100644
--- a/src/mail/em-subscription-editor.c
+++ b/src/mail/em-subscription-editor.c
@@ -711,7 +711,6 @@ subscription_editor_pick_shown (EMSubscriptionEditor *editor,
                TreeRowData *tree_row_data;
                gboolean is_expanded = FALSE;
 
-               found = FALSE;
                tree_row_data = subscription_editor_tree_row_data_from_iter (
                        tree_view, tree_model, &iter, &is_expanded);
 
diff --git a/src/modules/calendar/e-cal-shell-content.c b/src/modules/calendar/e-cal-shell-content.c
index fa9c1ffc08..15bb59fc28 100644
--- a/src/modules/calendar/e-cal-shell-content.c
+++ b/src/modules/calendar/e-cal-shell-content.c
@@ -428,7 +428,8 @@ cal_shell_content_datepicker_selection_changed_cb (ECalendarItem *calitem,
        g_date_clear (&sel_start, 1);
        g_date_clear (&sel_end, 1);
 
-       e_calendar_item_get_selection (calitem, &sel_start, &sel_end);
+       if (!e_calendar_item_get_selection (calitem, &sel_start, &sel_end))
+               return;
 
        start_julian = g_date_get_julian (&sel_start);
        end_julian = g_date_get_julian (&sel_end);
@@ -622,7 +623,8 @@ cal_shell_content_datepicker_button_press_cb (ECalendar *calendar,
                g_date_clear (&sel_start, 1);
                g_date_clear (&sel_end, 1);
 
-               e_calendar_item_get_selection (calitem, &sel_start, &sel_end);
+               if (!e_calendar_item_get_selection (calitem, &sel_start, &sel_end))
+                       return FALSE;
 
                /* Switch to a day view on a double-click */
                e_cal_shell_content_change_view (cal_shell_content, E_CAL_VIEW_KIND_DAY, &sel_start, 
&sel_start, FALSE);
diff --git a/src/modules/calendar/e-cal-shell-view.c b/src/modules/calendar/e-cal-shell-view.c
index f80a711e6b..e8d051f030 100644
--- a/src/modules/calendar/e-cal-shell-view.c
+++ b/src/modules/calendar/e-cal-shell-view.c
@@ -90,7 +90,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
        ECalDataModel *data_model;
        GtkRadioAction *action;
        ICalTimezone *timezone;
-       const gchar *default_tzloc = NULL;
        ICalTime *current_time;
        time_t start_range;
        time_t end_range;
@@ -117,11 +116,6 @@ cal_shell_view_execute_search (EShellView *shell_view)
        now_time = time_day_begin (i_cal_time_as_timet (current_time));
        g_clear_object (&current_time);
 
-       if (timezone && timezone != i_cal_timezone_get_utc_timezone ())
-               default_tzloc = i_cal_timezone_get_location (timezone);
-       if (!default_tzloc)
-               default_tzloc = "";
-
        action = GTK_RADIO_ACTION (ACTION (CALENDAR_SEARCH_ANY_FIELD_CONTAINS));
        value = gtk_radio_action_get_current_value (action);
 
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index 4bd63db67a..decdf848e3 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -1579,8 +1579,6 @@ e_mail_shell_view_update_labels_sensitivity (EShellWindow *shell_window,
                widget = gtk_widget_get_parent (widget);
        }
 
-       reader = E_MAIL_READER (e_mail_shell_content_get_mail_view 
(mail_shell_view->priv->mail_shell_content));
-
        action_group = e_mail_reader_get_action_group (reader, E_MAIL_READER_ACTION_GROUP_LABELS);
        if (action_group)
                gtk_action_group_set_sensitive (action_group, sensitive);
diff --git a/src/modules/text-highlight/e-mail-formatter-text-highlight.c 
b/src/modules/text-highlight/e-mail-formatter-text-highlight.c
index a89fd9f41d..62b6582de3 100644
--- a/src/modules/text-highlight/e-mail-formatter-text-highlight.c
+++ b/src/modules/text-highlight/e-mail-formatter-text-highlight.c
@@ -406,14 +406,7 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
                         *
                         * Just return FALSE here and EMailFormatter will automatically
                         * fall back to the default text/plain formatter */
-                       if (camel_content_type_is (ct, "text", "plain")) {
-                               g_free (font_family);
-                               g_free (font_size);
-                               g_free ((gchar *) argv[3]);
-                               pango_font_description_free (fd);
-                               goto exit;
-
-                       } else {
+                       if (!camel_content_type_is (ct, "text", "plain")) {
                                /* In case of any other content, force use of
                                 * text/plain formatter, because returning FALSE
                                 * for text/x-patch or application/php would show
@@ -432,6 +425,8 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
                g_free ((gchar *) argv[4]);
                pango_font_description_free (fd);
 
+               if (!success)
+                       goto exit;
        } else {
                CamelFolder *folder;
                const gchar *message_uid;
diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 62ac15323e..9a83d2c350 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -5321,134 +5321,136 @@ parse_html_into_blocks (EEditorPage *editor_page,
                if (camel_debug ("webkit:editor"))
                        printf ("\tto_process: '%s'\n", to_process);
 
-               if (to_process && !*to_process && processing_last) {
-                       g_free (to_process);
-                       to_process = g_strdup (next_token);
-                       next_token = NULL;
-               }
+               if (to_process) {
+                       if (!*to_process && processing_last) {
+                               g_free (to_process);
+                               to_process = g_strdup (next_token);
+                               next_token = NULL;
+                       }
 
-               to_insert_end = g_utf8_strlen (to_process, -1);
+                       to_insert_end = g_utf8_strlen (to_process, -1);
 
-               if ((with_br = strstr (to_process, "<br>"))) {
-                       if (with_br == to_process)
-                               to_insert_start += 4;
-               }
+                       if ((with_br = strstr (to_process, "<br>"))) {
+                               if (with_br == to_process)
+                                       to_insert_start += 4;
+                       }
 
-               if ((citation_start = strstr (to_process, "##CITATION_START"))) {
-                       if (with_br && citation_start == with_br + 4)
-                               to_insert_start += 18; /* + ## */
-                       else if (!with_br && citation_start == to_process)
-                               to_insert_start += 18; /* + ## */
-                       else
-                               to_insert_end -= 18; /* + ## */
-                       has_citation = TRUE;
-               }
+                       if ((citation_start = strstr (to_process, "##CITATION_START"))) {
+                               if (with_br && citation_start == with_br + 4)
+                                       to_insert_start += 18; /* + ## */
+                               else if (!with_br && citation_start == to_process)
+                                       to_insert_start += 18; /* + ## */
+                               else
+                                       to_insert_end -= 18; /* + ## */
+                               has_citation = TRUE;
+                       }
 
-               if ((citation_end = strstr (to_process, "##CITATION_END"))) {
-                       if (citation_end == to_process)
-                               to_insert_start += 16;
-                       else
-                               to_insert_end -= 16; /* + ## */
-               }
+                       if ((citation_end = strstr (to_process, "##CITATION_END"))) {
+                               if (citation_end == to_process)
+                                       to_insert_start += 16;
+                               else
+                                       to_insert_end -= 16; /* + ## */
+                       }
 
-               /* First BR */
-               if (with_br && prev_token == html->str)
-                       create_and_append_new_block (
-                               editor_page, parent, block_template, "<br id=\"-x-evo-first-br\">");
+                       /* First BR */
+                       if (with_br && prev_token == html->str)
+                               create_and_append_new_block (
+                                       editor_page, parent, block_template, "<br id=\"-x-evo-first-br\">");
 
-               if (with_br && citation_start && citation_start == with_br + 4) {
-                       create_and_append_new_block (
-                               editor_page, parent, block_template, "<br>");
+                       if (with_br && citation_start && citation_start == with_br + 4) {
+                               create_and_append_new_block (
+                                       editor_page, parent, block_template, "<br>");
 
-                       append_citation_mark (document, parent, "##CITATION_START##");
-               } else if (!with_br && citation_start == to_process) {
-                       append_citation_mark (document, parent, "##CITATION_START##");
-               }
+                               append_citation_mark (document, parent, "##CITATION_START##");
+                       } else if (!with_br && citation_start == to_process) {
+                               append_citation_mark (document, parent, "##CITATION_START##");
+                       }
 
-               if (citation_end && citation_end == to_process) {
-                       append_citation_mark (document, parent, "##CITATION_END##");
-               }
+                       if (citation_end && citation_end == to_process) {
+                               append_citation_mark (document, parent, "##CITATION_END##");
+                       }
 
-               if ((to_insert = g_utf8_substring (to_process, to_insert_start, to_insert_end)) && 
*to_insert) {
-                       gchar *truncated = g_strdup (to_insert);
-                       gchar *rest_to_insert;
+                       if ((to_insert = g_utf8_substring (to_process, to_insert_start, to_insert_end)) && 
*to_insert) {
+                               gchar *truncated = g_strdup (to_insert);
+                               gchar *rest_to_insert;
 
-                       if (camel_debug ("webkit:editor"))
-                               printf ("\tto_insert: '%s'\n", to_insert);
+                               if (camel_debug ("webkit:editor"))
+                                       printf ("\tto_insert: '%s'\n", to_insert);
 
-                       if (!*truncated && strlen (to_insert) > 0) {
-                               rest_to_insert = g_strdup (rest);
-                               g_free (truncated);
-                       } else {
-                               rest_to_insert = truncated;
-                       }
+                               if (!*truncated && strlen (to_insert) > 0) {
+                                       rest_to_insert = g_strdup (rest);
+                                       g_free (truncated);
+                               } else {
+                                       rest_to_insert = truncated;
+                               }
+
+                               replace_selection_markers (&rest_to_insert);
 
-                       replace_selection_markers (&rest_to_insert);
+                               if (surround_links_with_anchor (rest_to_insert)) {
+                                       gboolean is_email_address =
+                                               strstr (rest_to_insert, "@") &&
+                                               !strstr (rest_to_insert, "://");
 
-                       if (surround_links_with_anchor (rest_to_insert)) {
-                               gboolean is_email_address =
-                                       strstr (rest_to_insert, "@") &&
-                                       !strstr (rest_to_insert, "://");
+                                       if (is_email_address && !regex_email)
+                                               regex_email = g_regex_new (E_MAIL_PATTERN, 0, 0, NULL);
+                                       if (!is_email_address && !regex_link)
+                                               regex_link = g_regex_new (URL_PATTERN, 0, 0, NULL);
 
-                               if (is_email_address && !regex_email)
-                                       regex_email = g_regex_new (E_MAIL_PATTERN, 0, 0, NULL);
-                               if (!is_email_address && !regex_link)
-                                       regex_link = g_regex_new (URL_PATTERN, 0, 0, NULL);
+                                       truncated = g_regex_replace_eval (
+                                               is_email_address ? regex_email : regex_link,
+                                               rest_to_insert,
+                                               -1,
+                                               0,
+                                               G_REGEX_MATCH_NOTEMPTY,
+                                               create_anchor_for_link,
+                                               NULL,
+                                               NULL);
+
+                                       g_free (rest_to_insert);
+                                       rest_to_insert = truncated;
+                               }
 
+                               /* Do it after the anchor change */
                                truncated = g_regex_replace_eval (
-                                       is_email_address ? regex_email : regex_link,
+                                       regex_nbsp,
                                        rest_to_insert,
                                        -1,
                                        0,
-                                       G_REGEX_MATCH_NOTEMPTY,
-                                       create_anchor_for_link,
+                                       0,
+                                       (GRegexEvalCallback) replace_to_nbsp,
                                        NULL,
                                        NULL);
-
                                g_free (rest_to_insert);
                                rest_to_insert = truncated;
-                       }
-
-                       /* Do it after the anchor change */
-                       truncated = g_regex_replace_eval (
-                               regex_nbsp,
-                               rest_to_insert,
-                               -1,
-                               0,
-                               0,
-                               (GRegexEvalCallback) replace_to_nbsp,
-                               NULL,
-                               NULL);
-                       g_free (rest_to_insert);
-                       rest_to_insert = truncated;
-
-                       create_and_append_new_block (
-                               editor_page, parent, block_template, rest_to_insert);
 
-                       g_free (rest_to_insert);
-               } else if (to_insert) {
-                       if (!citation_start && (with_br || !citation_end))
                                create_and_append_new_block (
-                                       editor_page, parent, block_template, "<br>");
-                       else if (citation_end && citation_end == to_process &&
-                                next_token && g_str_has_prefix (next_token, "<br>")) {
-                               create_and_append_new_block (
-                                       editor_page, parent, block_template, "<br>");
+                                       editor_page, parent, block_template, rest_to_insert);
+
+                               g_free (rest_to_insert);
+                       } else if (to_insert) {
+                               if (!citation_start && (with_br || !citation_end))
+                                       create_and_append_new_block (
+                                               editor_page, parent, block_template, "<br>");
+                               else if (citation_end && citation_end == to_process &&
+                                        next_token && g_str_has_prefix (next_token, "<br>")) {
+                                       create_and_append_new_block (
+                                               editor_page, parent, block_template, "<br>");
+                               }
                        }
-               }
 
-               g_free (to_insert);
+                       g_free (to_insert);
 
-               if (with_br && citation_start && citation_start != with_br + 4)
-                       append_citation_mark (document, parent, "##CITATION_START##");
+                       if (with_br && citation_start && citation_start != with_br + 4)
+                               append_citation_mark (document, parent, "##CITATION_START##");
 
-               if (!with_br && citation_start && citation_start != to_process)
-                       append_citation_mark (document, parent, "##CITATION_START##");
+                       if (!with_br && citation_start && citation_start != to_process)
+                               append_citation_mark (document, parent, "##CITATION_START##");
 
-               if (citation_end && citation_end != to_process)
-                       append_citation_mark (document, parent, "##CITATION_END##");
+                       if (citation_end && citation_end != to_process)
+                               append_citation_mark (document, parent, "##CITATION_END##");
 
-               g_free (to_process);
+                       g_free (to_process);
+               }
 
                prev_token = next_token;
                next_br_token = (prev_token && *prev_token) ? strstr (prev_token + 1, "<br>") : NULL;
diff --git a/src/plugins/pst-import/pst-importer.c b/src/plugins/pst-import/pst-importer.c
index 2b2f04736f..13f3ea8830 100644
--- a/src/plugins/pst-import/pst-importer.c
+++ b/src/plugins/pst-import/pst-importer.c
@@ -1444,7 +1444,7 @@ contact_set_address (EContact *contact,
        EContactAddress *eaddress;
 
        if (address || city || country || po_box || postal_code || state || street) {
-               eaddress = g_new0 (EContactAddress, 1);
+               eaddress = e_contact_address_new ();
                if (po_box) {
                        eaddress->po = g_strdup (po_box);
                }
@@ -1471,6 +1471,7 @@ contact_set_address (EContact *contact,
                }
 
                e_contact_set (contact, id, eaddress);
+               e_contact_address_free (eaddress);
        }
 }
 


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