From: Sebastian Harl Date: Sun, 8 Mar 2015 21:47:51 +0000 (+0100) Subject: store: Advance expression iterators even if array access fails. X-Git-Tag: sysdb-0.8.0~131 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3a98a4db16092c17a70dffe71adaf9459fa9db2a;p=sysdb.git store: Advance expression iterators even if array access fails. Else, we'd have an endless loop as the caller doesn't know about that. --- 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 */