[evolution-data-server] Fix few Coverity scan issues
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Fix few Coverity scan issues
- Date: Mon, 20 Mar 2017 16:59:05 +0000 (UTC)
commit 782efdfa0b1b9ff1d6da0843057c30201736648a
Author: Milan Crha <mcrha redhat com>
Date: Mon Mar 20 17:58:31 2017 +0100
Fix few Coverity scan issues
.../backends/ldap/e-book-backend-ldap.c | 6 ++++-
src/addressbook/libebook-contacts/e-book-query.c | 1 +
.../libedata-book/e-book-backend-sqlitedb.c | 1 +
.../libedata-book/e-book-backend-summary.c | 1 +
src/camel/camel-db.c | 4 +-
src/libedataserverui/e-webdav-discover-widget.c | 2 +-
src/tools/addressbook-export/addressbook-export.c | 22 ++++++++-----------
7 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/src/addressbook/backends/ldap/e-book-backend-ldap.c
b/src/addressbook/backends/ldap/e-book-backend-ldap.c
index 0e28f64..d4b8232 100644
--- a/src/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/src/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -3818,7 +3818,11 @@ e_book_backend_ldap_build_query (EBookBackendLDAP *bl,
}
e_sexp_input_text (sexp, query, strlen (query));
- e_sexp_parse (sexp);
+ if (e_sexp_parse (sexp) == -1) {
+ g_warning ("%s: Error in parsing '%s': %s", G_STRFUNC, query, e_sexp_get_error (sexp));
+ g_object_unref (sexp);
+ return NULL;
+ }
r = e_sexp_eval (sexp);
diff --git a/src/addressbook/libebook-contacts/e-book-query.c
b/src/addressbook/libebook-contacts/e-book-query.c
index 214ac8e..d182f53 100644
--- a/src/addressbook/libebook-contacts/e-book-query.c
+++ b/src/addressbook/libebook-contacts/e-book-query.c
@@ -777,6 +777,7 @@ e_book_query_from_string (const gchar *query_string)
if (e_sexp_parse (sexp) == -1) {
g_warning ("%s: Error in parsing: %s", G_STRFUNC, e_sexp_get_error (sexp));
+ g_object_unref (sexp);
return NULL;
}
diff --git a/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
b/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
index 6768fed..23cdb36 100644
--- a/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/src/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -3318,6 +3318,7 @@ e_book_backend_sqlitedb_check_summary_query_locked (EBookBackendSqliteDB *ebsdb,
if (esexp_error == -1) {
if (invalid_query)
*invalid_query = TRUE;
+ g_object_unref (sexp);
return FALSE;
}
diff --git a/src/addressbook/libedata-book/e-book-backend-summary.c
b/src/addressbook/libedata-book/e-book-backend-summary.c
index df69281..79e46c3 100644
--- a/src/addressbook/libedata-book/e-book-backend-summary.c
+++ b/src/addressbook/libedata-book/e-book-backend-summary.c
@@ -1271,6 +1271,7 @@ e_book_backend_summary_search (EBookBackendSummary *summary,
esexp_error = e_sexp_parse (sexp);
if (esexp_error == -1) {
+ g_object_unref (sexp);
return NULL;
}
diff --git a/src/camel/camel-db.c b/src/camel/camel-db.c
index 6f0ce33..999d5cb 100644
--- a/src/camel/camel-db.c
+++ b/src/camel/camel-db.c
@@ -2342,7 +2342,7 @@ cdb_delete_ids (CamelDB *cdb,
GError **error)
{
gchar *tmp;
- gint ret = 0;
+ gint ret;
gboolean first = TRUE;
GString *str = g_string_new ("DELETE FROM ");
const GList *iterator;
@@ -2373,7 +2373,7 @@ cdb_delete_ids (CamelDB *cdb,
g_string_append (str, ")");
- ret = ret == -1 ? ret : camel_db_add_to_transaction (cdb, str->str, error);
+ ret = camel_db_add_to_transaction (cdb, str->str, error);
if (ret == -1)
camel_db_abort_transaction (cdb, NULL);
diff --git a/src/libedataserverui/e-webdav-discover-widget.c b/src/libedataserverui/e-webdav-discover-widget.c
index 944a583..c637540 100644
--- a/src/libedataserverui/e-webdav-discover-widget.c
+++ b/src/libedataserverui/e-webdav-discover-widget.c
@@ -644,7 +644,7 @@ e_webdav_discover_content_trust_prompt_done_cb (GObject *source_object,
e_webdav_discover_content_refresh_done_cb, rd);
} else {
g_cancellable_cancel (rd->cancellable);
- g_cancellable_set_error_if_cancelled (rd->cancellable, &local_error);
+ g_warn_if_fail (g_cancellable_set_error_if_cancelled (rd->cancellable, &local_error));
g_simple_async_result_take_error (rd->simple, local_error);
local_error = NULL;
g_simple_async_result_complete (rd->simple);
diff --git a/src/tools/addressbook-export/addressbook-export.c
b/src/tools/addressbook-export/addressbook-export.c
index 65c6ab4..11c2c6c 100644
--- a/src/tools/addressbook-export/addressbook-export.c
+++ b/src/tools/addressbook-export/addressbook-export.c
@@ -78,7 +78,7 @@ action_list_folders_init (ActionContext *p_actctx)
EBookClient *book_client;
EBookQuery *query;
ESource *source;
- GSList *contacts;
+ GSList *contacts = NULL;
const gchar *display_name;
const gchar *uid;
gchar *query_str;
@@ -108,8 +108,8 @@ action_list_folders_init (ActionContext *p_actctx)
query_str = e_book_query_to_string (query);
e_book_query_unref (query);
- e_book_client_get_contacts_sync (
- book_client, query_str, &contacts, NULL, NULL);
+ if (!e_book_client_get_contacts_sync (book_client, query_str, &contacts, NULL, NULL))
+ contacts = NULL;
display_name = e_source_get_display_name (source);
uid = e_source_get_uid (source);
@@ -123,9 +123,7 @@ action_list_folders_init (ActionContext *p_actctx)
"\"%s\",\"%s\",%d\n",
uid, display_name, g_slist_length (contacts));
- g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_slist_free (contacts);
-
+ g_slist_free_full (contacts, g_object_unref);
g_object_unref (book_client);
}
@@ -804,7 +802,7 @@ action_list_cards_init (ActionContext *p_actctx)
EBookClient *book_client;
EBookQuery *query;
ESource *source;
- GSList *contacts;
+ GSList *contacts = NULL;
const gchar *uid;
gchar *query_str;
GError *error = NULL;
@@ -851,13 +849,11 @@ action_list_cards_init (ActionContext *p_actctx)
query_str = e_book_query_to_string (query);
e_book_query_unref (query);
- e_book_client_get_contacts_sync (
- book_client, query_str, &contacts, NULL, &error);
-
- action_list_cards (contacts, p_actctx);
+ if (e_book_client_get_contacts_sync (book_client, query_str, &contacts, NULL, &error)) {
+ action_list_cards (contacts, p_actctx);
+ g_slist_free_full (contacts, g_object_unref);
+ }
- g_slist_foreach (contacts, (GFunc) g_object_unref, NULL);
- g_slist_free (contacts);
g_object_unref (book_client);
if (error != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]