[evolution-data-server] Bug #597816 - Do not crash on incorrect parameters used in sexp to SQL
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #597816 - Do not crash on incorrect parameters used in sexp to SQL
- Date: Mon, 4 Jan 2010 14:08:28 +0000 (UTC)
commit 3c901c5dcd47ea8bfa4149547e49c15b81f96eac
Author: Milan Crha <mcrha redhat com>
Date: Mon Jan 4 15:05:37 2010 +0100
Bug #597816 - Do not crash on incorrect parameters used in sexp to SQL
camel/camel-search-sql-sexp.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/camel/camel-search-sql-sexp.c b/camel/camel-search-sql-sexp.c
index 97928d5..80355f0 100644
--- a/camel/camel-search-sql-sexp.c
+++ b/camel/camel-search-sql-sexp.c
@@ -210,6 +210,8 @@ eval_eq(struct _ESExp *f, gint argc, struct _ESExpTerm **argv, gpointer data)
g_string_append (str, " )");
r->value.string = str->str;
g_string_free(str, FALSE);
+ } else {
+ r->value.string = g_strdup ("(0)");
}
return r;
}
@@ -458,12 +460,17 @@ user_flag(struct _ESExp *f, gint argc, struct _ESExpResult **argv, gpointer data
d(printf("executing user-flag: %d", argc));
- tstr = g_strdup_printf("%c%s%c", '%', argv[0]->value.string, '%');
- qstr = get_db_safe_string(tstr);
- g_free(tstr);
r = e_sexp_result_new(f, ESEXP_RES_STRING);
- r->value.string = g_strdup_printf("(labels LIKE %s)", qstr);
- g_free(qstr);
+
+ if (argc != 1) {
+ r->value.string = g_strdup ("(0)");
+ } else {
+ tstr = g_strdup_printf("%%%s%%", argv[0]->value.string);
+ qstr = get_db_safe_string(tstr);
+ g_free(tstr);
+ r->value.string = g_strdup_printf("(labels LIKE %s)", qstr);
+ g_free(qstr);
+ }
return r;
}
@@ -476,10 +483,15 @@ system_flag (struct _ESExp *f, gint argc, struct _ESExpResult **argv, gpointer d
d(printf("executing system-flag: %d", argc));
- tstr = camel_db_get_column_name(argv[0]->value.string);
r = e_sexp_result_new(f, ESEXP_RES_STRING);
- r->value.string = g_strdup_printf("(%s = 1)", tstr);
- g_free(tstr);
+
+ if (argc != 1) {
+ r->value.string = g_strdup ("(0)");
+ } else {
+ tstr = camel_db_get_column_name(argv[0]->value.string);
+ r->value.string = g_strdup_printf("(%s = 1)", tstr);
+ g_free(tstr);
+ }
return r;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]