[evolution-data-server/evolution-data-server-3-12] addressbook: Fix some potential NULL pointer dereferences with SQL
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] addressbook: Fix some potential NULL pointer dereferences with SQL
- Date: Tue, 20 May 2014 10:12:49 +0000 (UTC)
commit 52cc3a14423eb70aed14eadc3d015eafc93a463a
Author: Philip Withnall <philip withnall collabora co uk>
Date: Mon May 19 14:23:19 2014 +0100
addressbook: Fix some potential NULL pointer dereferences with SQL
The PreflightContext.constraints field may be NULL, especially when
calling query_preflight() with a newly-initialised context from
PREFLIGHT_CONTEXT_INIT.
Coverity issues: #1214492, #1214493
https://bugzilla.gnome.org/show_bug.cgi?id=730373
addressbook/libedata-book/e-book-sqlite.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
index 044d9b1..fd44da6 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -3826,7 +3826,7 @@ typedef struct {
typedef struct {
PreflightStatus status; /* result status */
- GPtrArray *constraints; /* main query */
+ GPtrArray *constraints; /* main query; may be NULL */
guint64 aux_mask; /* Bitmask of which auxiliary tables are needed in the query */
} PreflightContext;
@@ -4392,8 +4392,13 @@ query_preflight_check (PreflightContext *context,
context->status = PREFLIGHT_OK;
- elements = (QueryElement **) context->constraints->pdata;
- n_elements = context->constraints->len;
+ if (context->constraints != NULL) {
+ elements = (QueryElement **) context->constraints->pdata;
+ n_elements = context->constraints->len;
+ } else {
+ elements = NULL;
+ n_elements = 0;
+ }
for (i = 0; i < n_elements; i++) {
QueryFieldTest *test;
@@ -4636,7 +4641,7 @@ query_preflight_substitute_full_name (PreflightContext *context,
{
gint i, j;
- for (i = 0; i < context->constraints->len; i++) {
+ for (i = 0; context->constraints != NULL && i < context->constraints->len; i++) {
SummaryField *family_name, *given_name, *nickname;
QueryElement *element;
QueryFieldTest *test;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]