CamelFolderSearch: Add argument guards to set() functions.
authorMatthew Barnes <mbarnes@redhat.com>
Fri, 6 Jan 2012 17:12:53 +0000 (12:12 -0500)
committerMatthew Barnes <mbarnes@redhat.com>
Fri, 6 Jan 2012 17:19:06 +0000 (12:19 -0500)
camel/camel-folder-search.c
camel/camel-folder-search.h

index 416634c..3be7b3d 100644 (file)
@@ -266,6 +266,9 @@ void
 camel_folder_search_set_folder (CamelFolderSearch *search,
                                 CamelFolder *folder)
 {
+       g_return_if_fail (CAMEL_IS_FOLDER_SEARCH (search));
+       g_return_if_fail (CAMEL_IS_FOLDER (folder));
+
        search->folder = folder;
 }
 
@@ -283,13 +286,15 @@ void
 camel_folder_search_set_summary (CamelFolderSearch *search,
                                  GPtrArray *summary)
 {
+       g_return_if_fail (CAMEL_IS_FOLDER_SEARCH (search));
+
        search->summary = summary;
 }
 
 /**
  * camel_folder_search_set_body_index:
  * @search:
- * @index:
+ * @body_index:
  *
  * Set the index representing the contents of all messages
  * in this folder.  If this is not set, then the folder implementation
@@ -298,13 +303,19 @@ camel_folder_search_set_summary (CamelFolderSearch *search,
  **/
 void
 camel_folder_search_set_body_index (CamelFolderSearch *search,
-                                    CamelIndex *index)
+                                    CamelIndex *body_index)
 {
-       if (search->body_index)
+       g_return_if_fail (CAMEL_IS_FOLDER_SEARCH (search));
+
+       if (body_index != NULL) {
+               g_return_if_fail (CAMEL_IS_INDEX (body_index));
+               g_object_ref (body_index);
+       }
+
+       if (search->body_index != NULL)
                g_object_unref (search->body_index);
-       search->body_index = index;
-       if (index)
-               g_object_ref (index);
+
+       search->body_index = body_index;
 }
 
 /**
index a1b2448..b3a7a4a 100644 (file)
@@ -158,7 +158,7 @@ void camel_folder_search_construct (CamelFolderSearch *search);
 /* This stuff currently gets cleared when you run a search ... what on earth was i thinking ... */
 void camel_folder_search_set_folder (CamelFolderSearch *search, CamelFolder *folder);
 void camel_folder_search_set_summary (CamelFolderSearch *search, GPtrArray *summary);
-void camel_folder_search_set_body_index (CamelFolderSearch *search, CamelIndex *index);
+void camel_folder_search_set_body_index (CamelFolderSearch *search, CamelIndex *body_index);
 /* this interface is deprecated */
 GPtrArray *camel_folder_search_execute_expression (CamelFolderSearch *search, const gchar *expr, GError **error);