diff --git a/src/core/store.c b/src/core/store.c
index e6aeaf63e86f3c8a6d56e7682f065801396e481d..ab37e689641ec52b42f844bb5f1f1d3cd6236d63 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
tmp.data.datetime = obj->interval;
break;
case SDB_FIELD_BACKEND:
- {
+ if (! res)
+ return 0;
tmp.type = SDB_TYPE_ARRAY | SDB_TYPE_STRING;
tmp.data.array.length = obj->backends_num;
tmp.data.array.values = obj->backends;
return sdb_data_copy(res, &tmp);
- }
+ case SDB_FIELD_VALUE:
+ if (obj->type != SDB_ATTRIBUTE)
+ return -1;
+ if (! res)
+ return 0;
+ return sdb_data_copy(res, &ATTR(obj)->value);
default:
return -1;
}
sdb_store_scan(int type, sdb_store_matcher_t *m, sdb_store_matcher_t *filter,
sdb_store_lookup_cb cb, void *user_data)
{
- sdb_avltree_iter_t *host_iter;
+ sdb_avltree_iter_t *host_iter = NULL;
int status = 0;
if (! cb)
pthread_rwlock_rdlock(&host_lock);
- host_iter = sdb_avltree_get_iter(hosts);
- if (! host_iter)
- status = -1;
+ if (hosts) {
+ host_iter = sdb_avltree_get_iter(hosts);
+ if (! host_iter)
+ status = -1;
+ }
/* has_next returns false if the iterator is NULL */
while (sdb_avltree_iter_has_next(host_iter)) {