[evolution-ews] Bug #672448 memory corruption related and other issues
- From: Punit Jain <jpunit src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #672448 memory corruption related and other issues
- Date: Mon, 26 Mar 2012 18:15:10 +0000 (UTC)
commit c7edc9187431d09c1fa4e42ea814c152f7174e62
Author: Punit Jain <jpunit suse com>
Date: Mon Mar 26 23:44:21 2012 +0530
Bug #672448 memory corruption related and other issues
src/utils/e-ews-query-to-restriction.c | 204 ++++++++++++++++++-------------
1 files changed, 118 insertions(+), 86 deletions(-)
---
diff --git a/src/utils/e-ews-query-to-restriction.c b/src/utils/e-ews-query-to-restriction.c
index 2d26241..079eb79 100644
--- a/src/utils/e-ews-query-to-restriction.c
+++ b/src/utils/e-ews-query-to-restriction.c
@@ -34,68 +34,84 @@
#define d(x) x
#define WRITE_CONTAINS_MESSAGE(msg, mode, compare, uri, val) \
- e_soap_message_start_element (msg, "Contains", NULL, NULL); \
- e_soap_message_add_attribute (msg, "ContainmentMode", mode, NULL, NULL); \
- e_soap_message_add_attribute (msg, "ContainmentComparison", compare, NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "Contains", NULL, NULL); \
+ e_soap_message_add_attribute (msg, "ContainmentMode", mode, NULL, NULL); \
+ e_soap_message_add_attribute (msg, "ContainmentComparison", compare, NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_CONTAINS_MESSAGE_INDEXED(msg, mode, compare, uri, index, val) \
- e_soap_message_start_element (msg, "Contains", NULL, NULL); \
- e_soap_message_add_attribute (msg, "ContainmentMode", mode, NULL, NULL); \
- e_soap_message_add_attribute (msg, "ContainmentComparison", compare, NULL, NULL); \
- e_soap_message_start_element (msg, "IndexedFieldURI", NULL, NULL); \
- e_soap_message_add_attribute (msg, "FieldURI", uri, NULL, NULL); \
- e_soap_message_add_attribute (msg, "FieldIndex", index, NULL, NULL); \
- e_soap_message_end_element (msg); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "Contains", NULL, NULL); \
+ e_soap_message_add_attribute (msg, "ContainmentMode", mode, NULL, NULL); \
+ e_soap_message_add_attribute (msg, "ContainmentComparison", compare, NULL, NULL); \
+ e_soap_message_start_element (msg, "IndexedFieldURI", NULL, NULL); \
+ e_soap_message_add_attribute (msg, "FieldURI", uri, NULL, NULL); \
+ e_soap_message_add_attribute (msg, "FieldIndex", index, NULL, NULL); \
+ e_soap_message_end_element (msg); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_EXISTS_MESSAGE(msg, uri) \
- e_soap_message_start_element (msg, "Exists", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri);\
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "Exists", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri);\
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_GREATER_THAN_OR_EQUAL_TO_MESSAGE(msg, uri, val) \
- e_soap_message_start_element (msg, "IsGreaterThanOrEqualTo", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
- e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "IsGreaterThanOrEqualTo", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
+ e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_LESS_THAN_OR_EQUAL_TO_MESSAGE(msg, uri, val) \
- e_soap_message_start_element (msg, "IsLessThanOrEqualTo", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
- e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "IsLessThanOrEqualTo", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
+ e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_GREATER_THAN_MESSAGE(msg, uri, val) \
- e_soap_message_start_element (msg, "IsGreaterThan", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
- e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "IsGreaterThan", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
+ e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_LESS_THAN_MESSAGE(msg, uri, val) \
- e_soap_message_start_element (msg, "IsLessThan", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
- e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "IsLessThan", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
+ e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
#define WRITE_IS_EQUAL_TO_MESSAGE(msg, uri, val) \
- e_soap_message_start_element (msg, "IsEqualTo", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
- e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
- e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
- e_soap_message_end_element (msg); \
- e_soap_message_end_element (msg);
+ G_STMT_START { \
+ e_soap_message_start_element (msg, "IsEqualTo", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", uri); \
+ e_soap_message_start_element (msg, "FieldURIOrConstant", NULL, NULL); \
+ e_ews_message_write_string_parameter_with_attribute (msg, "Constant", NULL, NULL, "Value", val); \
+ e_soap_message_end_element (msg); \
+ e_soap_message_end_element (msg); \
+ } G_STMT_END
typedef enum {
MATCH_CONTAINS,
@@ -215,7 +231,7 @@ e_ews_implement_contact_contains (ESExp *f,
msg = (ESoapMessage *) data;
if (argc > 1 && argv[0]->type == ESEXP_RES_STRING) {
- gchar *field;
+ const gchar *field;
field = argv[0]->value.string;
if (argv[1]->type == ESEXP_RES_STRING && argv[1]->value.string != NULL) {
@@ -232,8 +248,8 @@ e_ews_implement_contact_contains (ESExp *f,
if (!strcmp (field, "full_name")) {
gint n = 0;
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
e_soap_message_start_element (msg, "Or", NULL, NULL);
while (n < G_N_ELEMENTS (contact_field)) {
@@ -246,8 +262,8 @@ e_ews_implement_contact_contains (ESExp *f,
} else if (!strcmp (field, "x-evolution-any-field")) {
gint n = 0;
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
e_soap_message_start_element (msg, "Or", NULL, NULL);
while (n < G_N_ELEMENTS (contact_field)) {
@@ -264,9 +280,9 @@ e_ews_implement_contact_contains (ESExp *f,
}
e_soap_message_end_element (msg);
} else if (!strcmp (field, "email")) {
- gchar *value = NULL;
+ const gchar *value;
gint n = 0;
- value = g_strdup (argv[1]->value.string);
+ value = argv[1]->value.string;
e_soap_message_start_element (msg, "Or", NULL, NULL);
while (n < G_N_ELEMENTS (email_index)) {
@@ -275,12 +291,13 @@ e_ews_implement_contact_contains (ESExp *f,
}
e_soap_message_end_element (msg);
} else if (!strcmp (field, "category_list")) {
- gchar *value = NULL;
-
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, mode, "IgnoreCase", "item:Categories", value);
}
+
+ g_free (mode);
}
}
@@ -344,53 +361,52 @@ calendar_func_contains (ESExp *f,
msg = (ESoapMessage *) data;
if (argc > 1 && argv[0]->type == ESEXP_RES_STRING) {
- gchar *field;
+ const gchar *field;
field = argv[0]->value.string;
if (argv[1]->type == ESEXP_RES_STRING && argv[1]->value.string[0] != 0) {
if (!g_strcmp0 (field, "summary")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "item:Subject", value);
} else if (!g_strcmp0 (field, "description")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "item:Body", value);
} else if (!g_strcmp0 (field, "location")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "calendar:Location", value);
} else if (!g_strcmp0 (field, "attendee")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
e_soap_message_start_element (msg, "Or", NULL, NULL);
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "calendar:RequiredAttendees", value);
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "calendar:OptionalAttendees", value);
e_soap_message_end_element (msg);
} else if (!g_strcmp0 (field, "organizer")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "calendar:Organizer", value);
} else if (!g_strcmp0 (field, "classification")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "item:Sensitivity", value);
} else if (!g_strcmp0 (field, "priority")) {
- gchar *value = NULL;
- value = g_strdup (argv[1]->value.string);
+ const gchar *value;
+ value = argv[1]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "item:Importance", value);
} else if (!g_strcmp0 (field, "any")) {
- gchar *value = NULL;
+ const gchar *value;
gint n = 0;
-
- value = g_strdup (argv[1]->value.string);
+ value = argv[1]->value.string;
e_soap_message_start_element (msg, "Or", NULL, NULL);
while (n < G_N_ELEMENTS (calendar_field)) {
@@ -428,7 +444,7 @@ calendar_func_has_categories (ESExp *f,
msg = (ESoapMessage *) data;
if (argc == 1 && argv[0]->type == ESEXP_RES_STRING) {
- gchar *value;
+ const gchar *value;
value = argv[0]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "item:Categories", value);
@@ -524,6 +540,9 @@ calendar_func_occur_in_time_range (ESExp *f,
r = e_sexp_result_new (f, ESEXP_RES_UNDEFINED);
+ g_free (start);
+ g_free (end);
+
return r;
}
@@ -554,7 +573,7 @@ message_func_body_contains (ESExp *f,
msg = (ESoapMessage *) data;
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *value;
+ const gchar *value;
value = argv[0]->value.string;
WRITE_CONTAINS_MESSAGE (msg, "Substring", "IgnoreCase", "item:Body", value);
@@ -589,11 +608,11 @@ common_message_func_header_contains (ESExp *f,
mode = g_strdup ("Substring");
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *headername;
+ const gchar *headername;
headername = argv[0]->value.string;
if (argv[1]->type == ESEXP_RES_STRING) {
- gchar *value;
+ const gchar *value;
value = argv[1]->value.string;
if (!g_ascii_strcasecmp(headername, "subject")) {
@@ -612,6 +631,8 @@ common_message_func_header_contains (ESExp *f,
r = e_sexp_result_new (f, ESEXP_RES_UNDEFINED);
+ g_free (mode);
+
return r;
}
@@ -627,7 +648,7 @@ message_func_header_exists (ESExp *f,
msg = (ESoapMessage *) data;
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *headername;
+ const gchar *headername;
headername = argv[0]->value.string;
if (!g_ascii_strcasecmp(headername, "subject")) {
@@ -660,10 +681,10 @@ message_func_system_flag (ESExp *f,
msg = (ESoapMessage *) data;
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *name;
+ const gchar *name;
name = argv[0]->value.string;
if (!g_ascii_strcasecmp(name, "Attachments")) {
- WRITE_EXISTS_MESSAGE (msg, "item:HasAttachments")
+ WRITE_EXISTS_MESSAGE (msg, "item:HasAttachments");
} else if (!g_ascii_strcasecmp(name, "deleted") || !g_ascii_strcasecmp(name, "junk")) {
r = e_sexp_result_new (f, ESEXP_RES_BOOL);
r->value.boolean = FALSE;
@@ -769,7 +790,9 @@ func_eq (ESExp *f,
}
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *name, *field_uri = NULL;
+ const gchar *name;
+ gchar *field_uri = NULL;
+
name = argv[0]->value.string;
if (!g_strcmp0 (name, "sent-date")) {
@@ -785,7 +808,9 @@ func_eq (ESExp *f,
date = e_ews_make_timestamp (time);
WRITE_IS_EQUAL_TO_MESSAGE (msg, field_uri, date);
+ g_free (date);
}
+ g_free (field_uri);
}
r = e_sexp_result_new (f, ESEXP_RES_UNDEFINED);
@@ -810,8 +835,10 @@ func_gt (ESExp *f,
}
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *name, *field_uri = NULL;
+ const gchar *name;
+ gchar *field_uri = NULL;
gboolean is_time = FALSE;
+
name = argv[0]->value.string;
if (!g_strcmp0 (name, "sent-date")) {
@@ -833,6 +860,7 @@ func_gt (ESExp *f,
date = e_ews_make_timestamp (time);
WRITE_GREATER_THAN_MESSAGE (msg, field_uri, date);
+ g_free (date);
} else {
gint value;
gchar val_str[16];
@@ -844,6 +872,7 @@ func_gt (ESExp *f,
WRITE_GREATER_THAN_MESSAGE (msg, field_uri, val_str);
}
}
+ g_free (field_uri);
}
r = e_sexp_result_new (f, ESEXP_RES_UNDEFINED);
@@ -868,7 +897,8 @@ func_lt (ESExp *f,
}
if (argv[0]->type == ESEXP_RES_STRING) {
- gchar *name, *field_uri = NULL;
+ const gchar *name;
+ gchar *field_uri = NULL;
gboolean is_time = FALSE;
name = argv[0]->value.string;
@@ -891,6 +921,7 @@ func_lt (ESExp *f,
date = e_ews_make_timestamp (time);
WRITE_LESS_THAN_MESSAGE (msg, field_uri, date);
+ g_free (date);
} else {
gint value;
gchar val_str[16];
@@ -902,6 +933,7 @@ func_lt (ESExp *f,
WRITE_LESS_THAN_MESSAGE (msg, field_uri, val_str);
}
}
+ g_free (field_uri);
}
r = e_sexp_result_new (f, ESEXP_RES_UNDEFINED);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]