[evolution-data-server/wip/mcrha/libical-glib] Address several issues reported by Coverity Scan
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/mcrha/libical-glib] Address several issues reported by Coverity Scan
- Date: Thu, 18 Apr 2019 16:56:39 +0000 (UTC)
commit 1793fe17dcd46b994e6b548dca6a21364b50e46e
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 18 18:58:15 2019 +0200
Address several issues reported by Coverity Scan
src/calendar/backends/weather/e-cal-backend-weather.c | 2 +-
src/calendar/libecal/e-cal-client.c | 13 ++-----------
src/calendar/libecal/e-cal-component.c | 6 +++---
src/calendar/libecal/e-cal-recur.c | 2 +-
src/calendar/libecal/e-cal-util.c | 3 ++-
src/calendar/libedata-cal/e-cal-meta-backend.c | 11 +++++++----
tests/libecal/test-cal-client-remove-object.c | 5 +++--
tests/libedata-book/test-book-meta-backend.c | 2 ++
8 files changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/src/calendar/backends/weather/e-cal-backend-weather.c
b/src/calendar/backends/weather/e-cal-backend-weather.c
index a1ec0c2cf..ac940f157 100644
--- a/src/calendar/backends/weather/e-cal-backend-weather.c
+++ b/src/calendar/backends/weather/e-cal-backend-weather.c
@@ -134,7 +134,7 @@ static void
put_component_to_store (ECalBackendWeather *cb,
ECalComponent *comp)
{
- e_cal_cache_put_component (cb->priv->cache, comp, NULL, 0, E_CACHE_IS_ONLINE, NULL, NULL);
+ g_warn_if_fail (e_cal_cache_put_component (cb->priv->cache, comp, NULL, 0, E_CACHE_IS_ONLINE, NULL,
NULL));
}
static gint
diff --git a/src/calendar/libecal/e-cal-client.c b/src/calendar/libecal/e-cal-client.c
index 998fddeda..007bccec9 100644
--- a/src/calendar/libecal/e-cal-client.c
+++ b/src/calendar/libecal/e-cal-client.c
@@ -6841,21 +6841,12 @@ e_cal_client_add_timezone (ECalClient *client,
{
GSimpleAsyncResult *simple;
AsyncContext *async_context;
- ICalComponent *icalcomp, *clone;
g_return_if_fail (E_IS_CAL_CLIENT (client));
g_return_if_fail (zone != NULL);
- icalcomp = i_cal_timezone_get_component (zone);
- g_return_if_fail (icalcomp != NULL);
-
async_context = g_slice_new0 (AsyncContext);
- async_context->zone = i_cal_timezone_new ();
-
- clone = i_cal_component_new_clone (icalcomp);
- i_cal_timezone_set_component (async_context->zone, clone);
- g_object_unref (icalcomp);
- g_object_unref (clone);
+ async_context->zone = e_cal_util_copy_timezone (zone);
simple = g_simple_async_result_new (
G_OBJECT (client), callback, user_data,
@@ -6866,7 +6857,7 @@ e_cal_client_add_timezone (ECalClient *client,
g_simple_async_result_set_op_res_gpointer (
simple, async_context, (GDestroyNotify) async_context_free);
- if (zone == i_cal_timezone_get_utc_timezone ())
+ if (!async_context->zone || zone == i_cal_timezone_get_utc_timezone ())
g_simple_async_result_complete_in_idle (simple);
else
g_simple_async_result_run_in_thread (
diff --git a/src/calendar/libecal/e-cal-component.c b/src/calendar/libecal/e-cal-component.c
index cb315c163..9a757adb2 100644
--- a/src/calendar/libecal/e-cal-component.c
+++ b/src/calendar/libecal/e-cal-component.c
@@ -2017,7 +2017,6 @@ get_period_list (ICalComponent *icalcomp,
if (value_type == I_CAL_VALUE_DATE || value_type == I_CAL_VALUE_DATETIME) {
period_kind = E_CAL_COMPONENT_PERIOD_DATETIME;
} else if (value_type == I_CAL_VALUE_PERIOD) {
- period_kind = E_CAL_COMPONENT_PERIOD_DURATION;
duration = i_cal_period_get_duration (icalperiod);
if (!duration ||
@@ -3157,10 +3156,11 @@ e_cal_component_has_simple_recurrence (ECalComponent *comp)
if (n_by_set_pos != 1)
goto cleanup;
pos = i_cal_recurrence_get_by_set_pos (rt, 0);
- } else if (pos < 0) {
- goto cleanup;
}
+ if (pos < 0)
+ goto cleanup;
+
switch (weekday) {
case I_CAL_MONDAY_WEEKDAY:
case I_CAL_TUESDAY_WEEKDAY:
diff --git a/src/calendar/libecal/e-cal-recur.c b/src/calendar/libecal/e-cal-recur.c
index fb81e84da..025067d9a 100644
--- a/src/calendar/libecal/e-cal-recur.c
+++ b/src/calendar/libecal/e-cal-recur.c
@@ -2251,7 +2251,7 @@ cal_object_get_rdate_end (CalObjTime *occ,
}
/* This should never happen. */
- if (cmp == 0) {
+ if (cmp == 0 || !rdate) {
#ifdef CAL_OBJ_DEBUG
g_debug ("%s: Recurrence date %s not found", G_STRFUNC, cal_obj_time_to_string (cc));
#endif
diff --git a/src/calendar/libecal/e-cal-util.c b/src/calendar/libecal/e-cal-util.c
index cef07e73f..1b0558e52 100644
--- a/src/calendar/libecal/e-cal-util.c
+++ b/src/calendar/libecal/e-cal-util.c
@@ -125,7 +125,8 @@ e_cal_util_copy_timezone (const ICalTimezone *zone)
ICalComponent *comp_copy;
comp_copy = i_cal_component_new_clone (comp);
- i_cal_timezone_set_component (zone_copy, comp_copy);
+ if (!i_cal_timezone_set_component (zone_copy, comp_copy))
+ g_clear_object (&zone_copy);
g_object_unref (comp_copy);
g_object_unref (comp);
}
diff --git a/src/calendar/libedata-cal/e-cal-meta-backend.c b/src/calendar/libedata-cal/e-cal-meta-backend.c
index 8ca9d8237..df3390850 100644
--- a/src/calendar/libedata-cal/e-cal-meta-backend.c
+++ b/src/calendar/libedata-cal/e-cal-meta-backend.c
@@ -2817,11 +2817,14 @@ ecmb_add_timezone_sync (ECalBackendSync *sync_backend,
ICalTimezone *zone;
zone = i_cal_timezone_new ();
- i_cal_timezone_set_component (zone, tz_comp);
+ if (!i_cal_timezone_set_component (zone, tz_comp))
+ g_clear_object (&zone);
- /* Add it only to memory, do not store it persistently into the ECalCache */
- e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (sync_backend), zone);
- g_object_unref (zone);
+ if (zone) {
+ /* Add it only to memory, do not store it persistently into the ECalCache */
+ e_timezone_cache_add_timezone (E_TIMEZONE_CACHE (sync_backend), zone);
+ g_object_unref (zone);
+ }
}
g_clear_object (&tz_comp);
diff --git a/tests/libecal/test-cal-client-remove-object.c b/tests/libecal/test-cal-client-remove-object.c
index a9cd44ca9..57ae12fff 100644
--- a/tests/libecal/test-cal-client-remove-object.c
+++ b/tests/libecal/test-cal-client-remove-object.c
@@ -112,17 +112,18 @@ test_remove_object_empty_uid (ETestServerFixture *fixture,
gconstpointer user_data)
{
ECalClient *cal_client;
+ gboolean success;
GError *error = NULL;
g_test_bug ("697705");
cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
- e_cal_client_remove_object_sync (
- cal_client, "", NULL, E_CAL_OBJ_MOD_ALL, E_CAL_OPERATION_FLAG_NONE, NULL, &error);
+ success = e_cal_client_remove_object_sync (cal_client, "", NULL, E_CAL_OBJ_MOD_ALL,
E_CAL_OPERATION_FLAG_NONE, NULL, &error);
g_assert_error (
error, E_CAL_CLIENT_ERROR,
E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND);
+ g_assert (!success);
g_clear_error (&error);
}
diff --git a/tests/libedata-book/test-book-meta-backend.c b/tests/libedata-book/test-book-meta-backend.c
index e63ae845a..577f54bc9 100644
--- a/tests/libedata-book/test-book-meta-backend.c
+++ b/tests/libedata-book/test-book-meta-backend.c
@@ -1341,6 +1341,7 @@ test_get_contact_list (EBookMetaBackend *meta_backend)
success = backend_sync_class->get_contact_list_sync (E_BOOK_BACKEND_SYNC (meta_backend),
"(is \"uid\" \"custom-3\")", &contacts, NULL, &error);
g_assert_no_error (error);
+ g_assert (success);
g_assert_cmpint (g_slist_length (contacts), ==, 1);
contact = contacts->data;
g_assert_nonnull (contact);
@@ -1371,6 +1372,7 @@ test_get_contact_list_uids (EBookMetaBackend *meta_backend)
success = backend_sync_class->get_contact_list_uids_sync (E_BOOK_BACKEND_SYNC (meta_backend),
"(is \"uid\" \"custom-3\")", &uids, NULL, &error);
g_assert_no_error (error);
+ g_assert (success);
g_assert_cmpint (g_slist_length (uids), ==, 1);
g_assert_nonnull (uids->data);
g_assert_cmpstr (uids->data, ==, "custom-3");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]