From 3a98a4db16092c17a70dffe71adaf9459fa9db2a Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 8 Mar 2015 22:47:51 +0100 Subject: [PATCH] store: Advance expression iterators even if array access fails. Else, we'd have an endless loop as the caller doesn't know about that. --- src/core/store_expr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/store_expr.c b/src/core/store_expr.c index 42ebcaa..11370bb 100644 --- a/src/core/store_expr.c +++ b/src/core/store_expr.c @@ -395,6 +395,7 @@ sdb_store_expr_iter_get_next(sdb_store_expr_iter_t *iter) { sdb_data_t null = SDB_DATA_INIT; sdb_data_t ret = SDB_DATA_INIT; + sdb_data_t tmp = SDB_DATA_INIT; if (! iter) return null; @@ -426,10 +427,13 @@ sdb_store_expr_iter_get_next(sdb_store_expr_iter_t *iter) if (iter->array_idx >= iter->array.data.array.length) return null; - if (sdb_data_array_get(&iter->array, iter->array_idx, &ret)) - return null; ++iter->array_idx; + if (sdb_data_array_get(&iter->array, iter->array_idx - 1, &ret)) + return null; + if (sdb_data_copy(&tmp, &ret)) + return null; + ret = tmp; return ret; } /* sdb_store_expr_iter_get_next */ -- 2.30.2