From: Sebastian Harl Date: Tue, 21 Oct 2014 06:17:17 +0000 (+0200) Subject: store: Let compare matchers fail if any of the operands is NULL. X-Git-Tag: sysdb-0.6.0~85 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=a8c781d6922ccd505b2d5830c391affaec0e9d44 store: Let compare matchers fail if any of the operands is NULL. --- diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 274ca02..e112f4c 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -379,7 +379,8 @@ match_gt(sdb_store_matcher_t *m, sdb_store_obj_t *obj, * specified stored object and filter. Returns a value less than, equal to, or * greater than zero if the value of the first expression compares less than, * equal to, or greater than the value of the second expression. Returns - * INT_MAX if any of the expressions could not be evaluated. + * INT_MAX if any of the expressions could not be evaluated or if any of them + * evaluated to NULL. */ static int cmp_expr(sdb_store_expr_t *e1, sdb_store_expr_t *e2, @@ -395,7 +396,9 @@ cmp_expr(sdb_store_expr_t *e1, sdb_store_expr_t *e2, return INT_MAX; } - if (v1.type == v2.type) + if (sdb_data_isnull(&v1) || (sdb_data_isnull(&v2))) + status = INT_MAX; + else if (v1.type == v2.type) status = sdb_data_cmp(&v1, &v2); else status = sdb_data_strcmp(&v1, &v2);