Blame SOURCES/evolution-3.22.6-coverity-scan-issues.patch

6159b2
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
6159b2
index 1d9091a..fefde1f 100644
6159b2
--- a/calendar/gui/itip-utils.c
6159b2
+++ b/calendar/gui/itip-utils.c
6159b2
@@ -2316,8 +2316,6 @@ reply_to_calendar_comp (ESourceRegistry *registry,
6159b2
 
6159b2
  cleanup:
6159b2
 
6159b2
-	if (comp != NULL)
6159b2
-		g_object_unref (comp);
6159b2
 	if (top_level != NULL)
6159b2
 		icalcomponent_free (top_level);
6159b2
 
6159b2
diff --git a/e-util/e-color-chooser-widget.c b/e-util/e-color-chooser-widget.c
6159b2
index 530f199..2ebd044 100644
6159b2
--- a/e-util/e-color-chooser-widget.c
6159b2
+++ b/e-util/e-color-chooser-widget.c
6159b2
@@ -203,6 +203,9 @@ find_swatch (GtkContainer *container)
6159b2
 		GtkWidget *widget = child->data;
6159b2
 		GtkWidget *swatch;
6159b2
 
6159b2
+		if (!widget)
6159b2
+			continue;
6159b2
+
6159b2
 		if (GTK_IS_CONTAINER (widget)) {
6159b2
 			swatch = find_swatch (GTK_CONTAINER (widget));
6159b2
 
6159b2
diff --git a/e-util/test-html-editor-units.c b/e-util/test-html-editor-units.c
6159b2
index 4de3c7e..cfaff58 100644
6159b2
--- a/e-util/test-html-editor-units.c
6159b2
+++ b/e-util/test-html-editor-units.c
6159b2
@@ -955,6 +955,7 @@ test_image_insert (TestFixture *fixture)
6159b2
 	gchar *image_data;
6159b2
 	gchar *image_data_base64;
6159b2
 	gsize image_data_length;
6159b2
+	gboolean success;
6159b2
 	GError *error = NULL;
6159b2
 
6159b2
 	if (!test_utils_process_commands (fixture,
6159b2
@@ -968,8 +969,9 @@ test_image_insert (TestFixture *fixture)
6159b2
 	uri = g_filename_to_uri (filename, NULL, &error);
6159b2
 	g_assert_no_error (error);
6159b2
 
6159b2
-	g_file_get_contents (filename, &image_data, &image_data_length, &error);
6159b2
+	success = g_file_get_contents (filename, &image_data, &image_data_length, &error);
6159b2
 	g_assert_no_error (error);
6159b2
+	g_assert (success);
6159b2
 
6159b2
 	g_free (filename);
6159b2
 
6159b2
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
6159b2
index 957b3dd..e536898 100644
6159b2
--- a/mail/e-mail-display.c
6159b2
+++ b/mail/e-mail-display.c
6159b2
@@ -525,15 +525,15 @@ headers_collapsed_signal_cb (GDBusConnection *connection,
6159b2
                              GVariant *parameters,
6159b2
                              EMailDisplay *display)
6159b2
 {
6159b2
-	gboolean expanded;
6159b2
+	gboolean collapsed = FALSE;
6159b2
 
6159b2
 	if (g_strcmp0 (signal_name, "HeadersCollapsed") != 0)
6159b2
 		return;
6159b2
 
6159b2
 	if (parameters)
6159b2
-		g_variant_get (parameters, "(b)", &expanded);
6159b2
+		g_variant_get (parameters, "(b)", &collapsed);
6159b2
 
6159b2
-	e_mail_display_set_headers_collapsed (display, expanded);
6159b2
+	e_mail_display_set_headers_collapsed (display, collapsed);
6159b2
 }
6159b2
 
6159b2
 static void
6159b2
diff --git a/mail/e-mail-free-form-exp.c b/mail/e-mail-free-form-exp.c
6159b2
index 39af793..da4bb6a 100644
6159b2
--- a/mail/e-mail-free-form-exp.c
6159b2
+++ b/mail/e-mail-free-form-exp.c
6159b2
@@ -76,12 +76,9 @@ mail_ffe_build_header_sexp (const gchar *word,
6159b2
 	camel_sexp_encode_string (encoded_word, word);
6159b2
 
6159b2
 	if (!header_names[1]) {
6159b2
-		if (!sexp)
6159b2
-			sexp = g_string_new ("");
6159b2
-	} else if (!sexp) {
6159b2
-		sexp = g_string_new ("(or ");
6159b2
+		sexp = g_string_new ("");
6159b2
 	} else {
6159b2
-		g_string_append (sexp, "(or ");
6159b2
+		sexp = g_string_new ("(or ");
6159b2
 	}
6159b2
 
6159b2
 	for (ii = 0; header_names[ii]; ii++) {
6159b2
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c
6159b2
index ef28ddd..02aff51 100644
6159b2
--- a/modules/calendar/e-cal-attachment-handler.c
6159b2
+++ b/modules/calendar/e-cal-attachment-handler.c
6159b2
@@ -347,7 +347,7 @@ attachment_handler_run_dialog (GtkWindow *parent,
6159b2
 				break;
6159b2
 			default:
6159b2
 				g_warn_if_reached ();
6159b2
-				return;
6159b2
+				goto exit;
6159b2
 		}
6159b2
 
6159b2
 		shell_view = e_shell_window_get_shell_view (shell_window,
6159b2
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
6159b2
index 1feb1b8..594890a 100644
6159b2
--- a/modules/calendar/e-cal-shell-content.c
6159b2
+++ b/modules/calendar/e-cal-shell-content.c
6159b2
@@ -2225,7 +2225,7 @@ e_cal_shell_content_update_filters (ECalShellContent *cal_shell_content,
6159b2
 		hide_completed_tasks_sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE);
6159b2
 
6159b2
 		if (hide_completed_tasks_sexp != NULL) {
6159b2
-			if (cal_filter != NULL) {
6159b2
+			if (*cal_filter) {
6159b2
 				gchar *filter;
6159b2
 
6159b2
 				filter = g_strdup_printf ("(and %s %s)", hide_completed_tasks_sexp, cal_filter);
6159b2
@@ -2235,7 +2235,7 @@ e_cal_shell_content_update_filters (ECalShellContent *cal_shell_content,
6159b2
 				cal_shell_content_update_model_filter (data_model, model, hide_completed_tasks_sexp, 0, 0);
6159b2
 			}
6159b2
 		} else {
6159b2
-			cal_shell_content_update_model_filter (data_model, model, cal_filter ? cal_filter : "#t", 0, 0);
6159b2
+			cal_shell_content_update_model_filter (data_model, model, *cal_filter ? cal_filter : "#t", 0, 0);
6159b2
 		}
6159b2
 
6159b2
 		g_free (hide_completed_tasks_sexp);
6159b2
@@ -2275,7 +2275,7 @@ e_cal_shell_content_update_filters (ECalShellContent *cal_shell_content,
6159b2
 				"(and (or (not (has-start?)) "
6159b2
 				"(occur-in-time-range? (make-time \"%s\") "
6159b2
 				"(make-time \"%s\") \"%s\")) %s)",
6159b2
-				iso_start, iso_end, default_tzloc, cal_filter ? cal_filter : "");
6159b2
+				iso_start, iso_end, default_tzloc, cal_filter);
6159b2
 
6159b2
 			cal_shell_content_update_model_filter (data_model, model, filter, 0, 0);
6159b2
 
6159b2
@@ -2283,7 +2283,7 @@ e_cal_shell_content_update_filters (ECalShellContent *cal_shell_content,
6159b2
 			g_free (iso_start);
6159b2
 			g_free (iso_end);
6159b2
 		} else {
6159b2
-			cal_shell_content_update_model_filter (data_model, model, cal_filter ? cal_filter : "#t", 0, 0);
6159b2
+			cal_shell_content_update_model_filter (data_model, model, *cal_filter ? cal_filter : "#t", 0, 0);
6159b2
 		}
6159b2
 	}
6159b2
 }
6159b2
diff --git a/modules/webkit-editor/e-webkit-editor.c b/modules/webkit-editor/e-webkit-editor.c
6159b2
index 9fb3060..4b56adf 100644
6159b2
--- a/modules/webkit-editor/e-webkit-editor.c
6159b2
+++ b/modules/webkit-editor/e-webkit-editor.c
6159b2
@@ -1781,8 +1781,7 @@ webkit_editor_insert_content (EContentEditor *editor,
6159b2
 		}
6159b2
 
6159b2
 		if (strstr (content, "data-evo-draft") && !(wk_editor->priv->html_mode)) {
6159b2
-			if (content && *content)
6159b2
-				set_convert_in_situ (wk_editor, TRUE);
6159b2
+			set_convert_in_situ (wk_editor, TRUE);
6159b2
 			wk_editor->priv->reload_in_progress = TRUE;
6159b2
 			webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), content, "file://");
6159b2
 			return;
6159b2
@@ -1799,8 +1798,7 @@ webkit_editor_insert_content (EContentEditor *editor,
6159b2
 					return;
6159b2
 				}
6159b2
 			}
6159b2
-			if (content && *content)
6159b2
-				set_convert_in_situ (wk_editor, TRUE);
6159b2
+			set_convert_in_situ (wk_editor, TRUE);
6159b2
 		}
6159b2
 
6159b2
 		wk_editor->priv->reload_in_progress = TRUE;
6159b2
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
6159b2
index b79ea50..0eb29bd 100644
6159b2
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
6159b2
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
6159b2
@@ -2722,12 +2722,9 @@ save_history_before_event_in_table (EEditorPage *editor_page,
6159b2
 		ev = g_new0 (EEditorHistoryEvent, 1);
6159b2
 		ev->type = HISTORY_TABLE_INPUT;
6159b2
 
6159b2
-		if (block) {
6159b2
-			e_editor_dom_selection_save (editor_page);
6159b2
-			ev->data.dom.from = g_object_ref (webkit_dom_node_clone_node_with_error (WEBKIT_DOM_NODE (block), TRUE, NULL));
6159b2
-			e_editor_dom_selection_restore (editor_page);
6159b2
-		} else
6159b2
-			ev->data.dom.from = NULL;
6159b2
+		e_editor_dom_selection_save (editor_page);
6159b2
+		ev->data.dom.from = g_object_ref (webkit_dom_node_clone_node_with_error (WEBKIT_DOM_NODE (block), TRUE, NULL));
6159b2
+		e_editor_dom_selection_restore (editor_page);
6159b2
 
6159b2
 		e_editor_dom_selection_get_coordinates (editor_page,
6159b2
 			&ev->before.start.x,
6159b2
@@ -5252,7 +5249,7 @@ parse_html_into_blocks (EEditorPage *editor_page,
6159b2
 		if (camel_debug ("webkit") || camel_debug ("webkit:editor"))
6159b2
 			printf ("\tto_process: '%s'\n", to_process);
6159b2
 
6159b2
-		if (!*to_process && processing_last) {
6159b2
+		if (to_process && !*to_process && processing_last) {
6159b2
 			g_free (to_process);
6159b2
 			to_process = g_strdup (next_token);
6159b2
 			next_token = NULL;
6159b2
@@ -15303,7 +15300,6 @@ e_editor_dom_selection_set_monospace (EEditorPage *editor_page,
6159b2
 	} else {
6159b2
 		gboolean is_bold = FALSE, is_italic = FALSE;
6159b2
 		gboolean is_underline = FALSE, is_strikethrough = FALSE;
6159b2
-		guint font_size = 0;
6159b2
 		WebKitDOMElement *tt_element;
6159b2
 		WebKitDOMNode *node;
6159b2
 
6159b2
@@ -16142,7 +16138,7 @@ process_block_to_block (EEditorPage *editor_page,
6159b2
 
6159b2
 				word_wrap_length =
6159b2
 					e_editor_page_get_word_wrap_length (editor_page);
6159b2
-				quote = citation_level ? citation_level * 2 : 0;
6159b2
+				quote = citation_level * 2;
6159b2
 
6159b2
 				element = e_editor_dom_wrap_paragraph_length (
6159b2
 					editor_page, element, word_wrap_length - quote);
6159b2
@@ -16487,8 +16483,7 @@ format_change_list_from_list (EEditorPage *editor_page,
6159b2
 				WEBKIT_DOM_ELEMENT (item), new_list, to);
6159b2
 
6159b2
 			webkit_dom_node_append_child (
6159b2
-				after_selection_end ?
6159b2
-					source_list_clone : WEBKIT_DOM_NODE (new_list),
6159b2
+				WEBKIT_DOM_NODE (new_list),
6159b2
 				WEBKIT_DOM_NODE (processed_list),
6159b2
 				NULL);
6159b2
 		} else if (node_is_list (item) && !after_selection_end) {
6159b2
@@ -16510,10 +16505,7 @@ format_change_list_from_list (EEditorPage *editor_page,
6159b2
 					WEBKIT_DOM_NODE (new_list), FALSE, NULL);
6159b2
 
6159b2
 				webkit_dom_node_append_child (
6159b2
-					after_selection_end ?
6159b2
-						source_list_clone : WEBKIT_DOM_NODE (new_list),
6159b2
-					clone,
6159b2
-					NULL);
6159b2
+					WEBKIT_DOM_NODE (new_list), clone, NULL);
6159b2
 
6159b2
 				while ((child = webkit_dom_node_get_first_child (item))) {
6159b2
 					webkit_dom_node_append_child (clone, child, NULL);
6159b2
@@ -16523,10 +16515,7 @@ format_change_list_from_list (EEditorPage *editor_page,
6159b2
 
6159b2
 				if (webkit_dom_node_get_first_child (item))
6159b2
 					webkit_dom_node_append_child (
6159b2
-						after_selection_end ?
6159b2
-							source_list_clone : WEBKIT_DOM_NODE (new_list),
6159b2
-						item,
6159b2
-						NULL);
6159b2
+						WEBKIT_DOM_NODE (new_list), item, NULL);
6159b2
 				else
6159b2
 					remove_node (item);
6159b2
 			} else {
6159b2
@@ -17351,10 +17340,8 @@ e_editor_dom_selection_get_coordinates (EEditorPage *editor_page,
6159b2
 		parent = webkit_dom_element_get_offset_parent (parent);
6159b2
 	}
6159b2
 
6159b2
-	if (start_x)
6159b2
-		*start_x = local_x;
6159b2
-	if (start_y)
6159b2
-		*start_y = local_y;
6159b2
+	*start_x = local_x;
6159b2
+	*start_y = local_y;
6159b2
 
6159b2
 	if (e_editor_dom_selection_is_collapsed (editor_page)) {
6159b2
 		*end_x = local_x;
6159b2
@@ -17379,10 +17366,8 @@ e_editor_dom_selection_get_coordinates (EEditorPage *editor_page,
6159b2
 		parent = webkit_dom_element_get_offset_parent (parent);
6159b2
 	}
6159b2
 
6159b2
-	if (end_x)
6159b2
-		*end_x = local_x;
6159b2
-	if (end_y)
6159b2
-		*end_y = local_y;
6159b2
+	*end_x = local_x;
6159b2
+	*end_y = local_y;
6159b2
 
6159b2
 	if (created_selection_markers)
6159b2
 		e_editor_dom_selection_restore (editor_page);
6159b2
diff --git a/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c b/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
6159b2
index 5853f0b..1bd5fe9 100644
6159b2
--- a/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
6159b2
+++ b/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
6159b2
@@ -1810,11 +1810,12 @@ undo_redo_replace_all (EEditorUndoRedoManager *manager,
6159b2
 			if (prev_event->type == HISTORY_REPLACE) {
6159b2
 				undo_redo_replace (editor_page, prev_event, undo);
6159b2
 				prev_item = prev_item->prev;
6159b2
-			} else
6159b2
+			} else {
6159b2
+				manager->priv->history = prev_item->next;
6159b2
 				break;
6159b2
+			}
6159b2
 		}
6159b2
 
6159b2
-		manager->priv->history = prev_item->next;
6159b2
 	}
6159b2
 }
6159b2
 
6159b2
@@ -2724,7 +2725,7 @@ e_editor_undo_redo_manager_redo (EEditorUndoRedoManager *manager)
6159b2
 			return;
6159b2
 	}
6159b2
 
6159b2
-	if (history->prev && history->prev->prev) {
6159b2
+	if (history->prev->prev) {
6159b2
 		event = history->prev->prev->data;
6159b2
 		if (event->type == HISTORY_AND) {
6159b2
 			manager->priv->history = manager->priv->history->prev->prev;
6159b2
diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c
6159b2
index 5edbdb3..89c6a71 100644
6159b2
--- a/plugins/mail-notification/mail-notification.c
6159b2
+++ b/plugins/mail-notification/mail-notification.c
6159b2
@@ -327,7 +327,10 @@ notify_default_action_cb (NotifyNotification *notification,
6159b2
 	if (!list)
6159b2
 		list = fallback;
6159b2
 
6159b2
-	g_return_if_fail (list != NULL);
6159b2
+	if (!list) {
6159b2
+		g_warn_if_reached ();
6159b2
+		return;
6159b2
+	}
6159b2
 
6159b2
 	/* Present the shell window. */
6159b2
 	shell_window = E_SHELL_WINDOW (list->data);
6159b2
diff --git a/smime/lib/e-cert-db.c b/smime/lib/e-cert-db.c
6159b2
index 237c912..2775cf8 100644
6159b2
--- a/smime/lib/e-cert-db.c
6159b2
+++ b/smime/lib/e-cert-db.c
6159b2
@@ -413,6 +413,9 @@ p12u_ucs2_ascii_conversion_function(PRBool	   toUnicode,
6159b2
 	it.data = inBuf;
6159b2
 	it.len = inBufLen;
6159b2
 	dup = SECITEM_DupItem(&it);
6159b2
+	if (!dup)
6159b2
+		return PR_FALSE;
6159b2
+
6159b2
 	/* If converting Unicode to ASCII, swap bytes before conversion
6159b2
 	 * as neccessary.
6159b2
 	 */
6159b2
@@ -425,8 +428,7 @@ p12u_ucs2_ascii_conversion_function(PRBool	   toUnicode,
6159b2
 	/* Perform the conversion. */
6159b2
 	ret = PORT_UCS2_UTF8Conversion (toUnicode, dup->data, dup->len,
6159b2
 					outBuf, maxOutBufLen, outBufLen);
6159b2
-	if (dup)
6159b2
-		SECITEM_ZfreeItem(dup, PR_TRUE);
6159b2
+	SECITEM_ZfreeItem(dup, PR_TRUE);
6159b2
 
6159b2
 #ifdef DEBUG_CONVERSION
6159b2
 	if (pk12_debugging) {
6159b2
diff --git a/web-extensions/e-dom-utils.c b/web-extensions/e-dom-utils.c
6159b2
index 28ac97e..c4f7d61 100644
6159b2
--- a/web-extensions/e-dom-utils.c
6159b2
+++ b/web-extensions/e-dom-utils.c
6159b2
@@ -522,7 +522,7 @@ add_css_rule_into_style_sheet (WebKitDOMDocument *document,
6159b2
 		rule_text = webkit_dom_css_rule_get_css_text (rule);
6159b2
 
6159b2
 		/* Find the start of the style => end of the selector */
6159b2
-		if (rule_text && selector && g_str_has_prefix (rule_text, selector) &&
6159b2
+		if (rule_text && g_str_has_prefix (rule_text, selector) &&
6159b2
 		    rule_text[selector_length] == ' ' && rule_text[selector_length + 1] == '{') {
6159b2
 			/* If exists remove it */
6159b2
 			webkit_dom_css_style_sheet_remove_rule (