From 8a88537be033d7659a51047c7244bd30e806296b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 19 Oct 2014 14:58:45 +0200 Subject: [PATCH] store: Return NULL if an attribute was not found. --- src/core/store_expr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/store_expr.c b/src/core/store_expr.c index 0a8757f..ed0589b 100644 --- a/src/core/store_expr.c +++ b/src/core/store_expr.c @@ -172,8 +172,16 @@ sdb_store_expr_eval(sdb_store_expr_t *expr, sdb_store_obj_t *obj, return sdb_data_copy(res, &expr->data); else if (expr->type == FIELD_VALUE) return sdb_store_get_field(obj, (int)expr->data.data.integer, res); - else if (expr->type == ATTR_VALUE) - return sdb_store_get_attr(obj, expr->data.data.string, res, filter); + else if (expr->type == ATTR_VALUE) { + status = sdb_store_get_attr(obj, expr->data.data.string, res, filter); + if ((status < 0) && obj) { + /* attribute does not exist => NULL */ + status = 0; + res->type = SDB_TYPE_STRING; + res->data.string = NULL; + } + return status; + } if (sdb_store_expr_eval(expr->left, obj, &v1, filter)) return -1; -- 2.30.2