summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@openismus.com>2014-02-25 16:14:29 +0100
committerMilan Crha <mcrha@redhat.com>2014-02-25 16:14:29 +0100
commitb752152aa42a3c188451b8c2fc08aaf76c56cadf (patch)
tree86cb38ac50d7edee97cef350f560c6ce60044f29
parent86a6596c05187022a9fd95a66cc43bbd7481cce3 (diff)
downloadevolution-data-server-b752152aa42a3c188451b8c2fc08aaf76c56cadf.tar.gz
Bug #710997 - Check some return values before use
Check that some return values are not NULL before using them, in functions that do not check, such as strcmp(), or before dereferencing.
-rw-r--r--addressbook/backends/file/e-book-backend-file.c2
-rw-r--r--addressbook/libedata-book/e-book-backend-sqlitedb-test.c2
-rw-r--r--addressbook/libedata-book/e-book-backend-sqlitedb.c4
-rw-r--r--calendar/backends/file/e-cal-backend-file.c6
-rw-r--r--calendar/backends/http/e-cal-backend-http.c9
-rw-r--r--calendar/libecal/e-cal-client.c8
-rw-r--r--calendar/libedata-cal/e-cal-backend-intervaltree.c25
-rw-r--r--calendar/libedata-cal/e-cal-backend.c9
8 files changed, 39 insertions, 26 deletions
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 958c3e77b..87cd8b9e2 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -963,7 +963,7 @@ book_view_thread (gpointer data)
fields_of_interest = e_data_book_view_get_fields_of_interest (book_view);
meta_contact = uid_rev_fields (fields_of_interest);
- if ( !strcmp (query, "(contains \"x-evolution-any-field\" \"\")")) {
+ if (query && !strcmp (query, "(contains \"x-evolution-any-field\" \"\")")) {
e_data_book_view_notify_progress (book_view, -1, _("Loading..."));
} else {
e_data_book_view_notify_progress (book_view, -1, _("Searching..."));
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb-test.c b/addressbook/libedata-book/e-book-backend-sqlitedb-test.c
index ba56ddb1c..3d3914766 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb-test.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb-test.c
@@ -96,7 +96,7 @@ search_db (EBookBackendSqliteDB *ebsdb,
g_print ("%s - query: %s \n", type, sexp);
op = type;
vcards = e_book_backend_sqlitedb_search (ebsdb, folderid, sexp, NULL, NULL, NULL, &error);
- if (error)
+ if (error || !vcards)
return;
s_data = vcards->data;
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c b/addressbook/libedata-book/e-book-backend-sqlitedb.c
index 9a3b4e630..7f5396cc4 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -1832,7 +1832,7 @@ e_book_backend_sqlitedb_new_full (const gchar *path,
indexed_fields = e_source_backend_summary_setup_get_indexed_fields (setup, &index_types, &n_indexed_fields);
/* No specified summary fields indicates the default summary configuration should be used */
- if (n_fields <= 0) {
+ if (n_fields <= 0 || !fields) {
ebsdb = e_book_backend_sqlitedb_new (path, emailid, folderid, folder_name, store_vcard, error);
g_free (fields);
g_free (index_types);
@@ -3553,7 +3553,7 @@ convert_string_value (EBookBackendSqliteDB *ebsdb,
ptr = normal;
}
- while ((c = *ptr++)) {
+ while (ptr && (c = *ptr++)) {
if (c == '\'') {
g_string_append_c (str, '\'');
} else if ((c == '%' || c == '^') && match != MATCH_REGEX) {
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index c793db551..058306030 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -1679,7 +1679,7 @@ e_cal_backend_file_get_object_list (ECalBackendSync *backend,
match_data.as_string = TRUE;
match_data.backend = E_CAL_BACKEND (backend);
- if (!strcmp (sexp, "#t"))
+ if (sexp && !strcmp (sexp, "#t"))
match_data.search_needed = FALSE;
match_data.obj_sexp = e_cal_backend_sexp_new (sexp);
@@ -1870,7 +1870,7 @@ e_cal_backend_file_start_view (ECalBackend *backend,
match_data.obj_sexp = e_data_cal_view_get_sexp (query);
match_data.view = query;
- if (!strcmp (match_data.query, "#t"))
+ if (match_data.query && !strcmp (match_data.query, "#t"))
match_data.search_needed = FALSE;
if (!match_data.obj_sexp) {
@@ -3683,7 +3683,7 @@ test_query_by_scanning_all_objects (ECalBackendFile *cbfile,
match_data.as_string = TRUE;
match_data.backend = E_CAL_BACKEND (cbfile);
- if (!strcmp (sexp, "#t"))
+ if (sexp && !strcmp (sexp, "#t"))
match_data.search_needed = FALSE;
match_data.obj_sexp = e_cal_backend_sexp_new (sexp);
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index bd910e32c..296d7d454 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -268,10 +268,13 @@ notify_and_remove_from_cache (gpointer key,
ECalComponent *comp = e_cal_component_new_from_string (calobj);
ECalComponentId *id = e_cal_component_get_id (comp);
- e_cal_backend_store_remove_component (cbhttp->priv->store, id->uid, id->rid);
- e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbhttp), id, comp, NULL);
+ if (id) {
+ e_cal_backend_store_remove_component (cbhttp->priv->store, id->uid, id->rid);
+ e_cal_backend_notify_component_removed (E_CAL_BACKEND (cbhttp), id, comp, NULL);
+
+ e_cal_component_free_id (id);
+ }
- e_cal_component_free_id (id);
g_object_unref (comp);
return TRUE;
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 2458324dd..02940a5e1 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -2362,13 +2362,15 @@ generate_instances (ECalClient *client,
continue;
}
- ci->start = icaltime_as_timet_with_zone (
- *dtstart.value, start_zone);
+ if (dtstart.value) {
+ ci->start = icaltime_as_timet_with_zone (
+ *dtstart.value, start_zone);
+ }
if (dtend.value)
ci->end = icaltime_as_timet_with_zone (
*dtend.value, end_zone);
- else if (icaltime_is_date (*dtstart.value))
+ else if (dtstart.value && icaltime_is_date (*dtstart.value))
ci->end = time_day_end (ci->start);
else
ci->end = ci->start;
diff --git a/calendar/libedata-cal/e-cal-backend-intervaltree.c b/calendar/libedata-cal/e-cal-backend-intervaltree.c
index 97e64b03c..3a72dc4d5 100644
--- a/calendar/libedata-cal/e-cal-backend-intervaltree.c
+++ b/calendar/libedata-cal/e-cal-backend-intervaltree.c
@@ -588,9 +588,9 @@ e_intervaltree_remove (EIntervalTree *tree,
const gchar *uid,
const gchar *rid)
{
- EIntervalNode *y;
- EIntervalNode *x;
- EIntervalNode *z;
+ EIntervalNode *y = NULL;
+ EIntervalNode *x = NULL;
+ EIntervalNode *z = NULL;
EIntervalNode *nil, *root;
gchar *key;
@@ -609,21 +609,23 @@ e_intervaltree_remove (EIntervalTree *tree,
y = ((z->left == nil) || (z->right == nil)) ? z :
intervaltree_node_next (tree, z);
+ g_return_val_if_fail (y, FALSE);
x = (y->left == nil) ? y->right : y->left;
+ g_return_val_if_fail (x, FALSE);
/* y is to be spliced out. x is it's only child */
x->parent = y->parent;
- if (root == x->parent)
+ if (root && root == x->parent)
root->left = x;
- else {
+ else if (y->parent) {
if (y == y->parent->left)
y->parent->left = x;
else
y->parent->right = x;
}
- if (y != z) {
+ if (z && y != z) {
/* y (the succesor of z) is the node to be spliced out */
g_return_val_if_fail (y != tree->priv->nil, FALSE);
@@ -634,10 +636,13 @@ e_intervaltree_remove (EIntervalTree *tree,
y->parent = z->parent;
z->left->parent = z->right->parent = y;
- if (z == z->parent->left)
- z->parent->left = y;
- else
- z->parent->right = y;
+ if (z->parent) {
+ if (z == z->parent->left)
+ z->parent->left = y;
+ else
+ z->parent->right = y;
+
+ }
fixup_min_max_fields (tree, x->parent);
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 109b5d799..a7374f038 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -4477,11 +4477,14 @@ e_cal_backend_empty_cache (ECalBackend *backend,
id = e_cal_component_get_id (comp);
- e_cal_backend_cache_remove_component (cache, id->uid, id->rid);
+ if (id) {
+ e_cal_backend_cache_remove_component (cache, id->uid, id->rid);
- e_cal_backend_notify_component_removed (backend, id, comp, NULL);
+ e_cal_backend_notify_component_removed (backend, id, comp, NULL);
+
+ e_cal_component_free_id (id);
+ }
- e_cal_component_free_id (id);
g_object_unref (comp);
}