[evolution/gnome-3-0] mail-autofilter.c: Add argument guards in public functions.



commit a96c93309ad3f137279ab0439dd6e590d7df8e7e
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri May 20 18:47:55 2011 -0400

    mail-autofilter.c: Add argument guards in public functions.
    
    This is related to bug #650587, but is not a proper fix.
    
    This commit just trades a crash for a runtime warning, but can be
    backported to the stable branch, whereas the changes required for the
    proper fix are too extensive to backport.
    
    (cherry picked from commit d5398d49ce3d2d672f8ad8c5bbb1c0f760233da5)

 mail/mail-autofilter.c |   12 +++++++++++-
 mail/mail-vfolder.c    |    2 ++
 2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 2055480..35ff22b 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -318,6 +318,9 @@ em_vfolder_rule_from_message (EMVFolderContext *context,
 	EMailSession *session;
 	gchar *euri = em_uri_from_camel (source);
 
+	g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (msg), NULL);
+
 	session = em_vfolder_context_get_session (context);
 
 	rule = em_vfolder_rule_new (session);
@@ -338,6 +341,9 @@ em_vfolder_rule_from_address (EMVFolderContext *context,
 	EMailSession *session;
 	gchar *euri = em_uri_from_camel (source);
 
+	g_return_val_if_fail (EM_IS_VFOLDER_CONTEXT (context), NULL);
+	g_return_val_if_fail (CAMEL_IS_INTERNET_ADDRESS (addr), NULL);
+
 	session = em_vfolder_context_get_session (context);
 
 	rule = em_vfolder_rule_new (session);
@@ -356,6 +362,9 @@ filter_rule_from_message (EMFilterContext *context,
 	EFilterRule *rule;
 	EFilterPart *part;
 
+	g_return_val_if_fail (EM_IS_FILTER_CONTEXT (context), NULL);
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (msg), NULL);
+
 	rule = em_filter_rule_new ();
 	rule_from_message (rule, E_RULE_CONTEXT (context), msg, flags);
 
@@ -378,7 +387,8 @@ filter_gui_add_from_message (EMailSession *session,
 	gchar *user, *system;
 	EFilterRule *rule;
 
-	g_return_if_fail (msg != NULL);
+	g_return_if_fail (E_IS_MAIL_SESSION (session));
+	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg));
 
 	fc = em_filter_context_new (session);
 	config_dir = mail_session_get_config_dir ();
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 5c349e2..3e5ae6f 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -1402,6 +1402,8 @@ vfolder_gui_add_rule (EMVFolderRule *rule)
 	GtkDialog *gd;
 	GtkWidget *container;
 
+	g_return_if_fail (EM_IS_VFOLDER_RULE (rule));
+
 	w = e_filter_rule_get_widget ((EFilterRule *)rule, (ERuleContext *)context);
 
 	gd = (GtkDialog *)gtk_dialog_new_with_buttons (



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