From c0b468c6e35aa1d9e77a80c9dda756222a72d4b2 Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Fri, 12 May 2023 23:51:31 -0400 Subject: [PATCH] Fix offset used before range check This use of offset 'rank' should follow the range check. --- gear-lib/libdict/libdict.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gear-lib/libdict/libdict.c b/gear-lib/libdict/libdict.c index 1509f7d4..9abcced9 100644 --- a/gear-lib/libdict/libdict.c +++ b/gear-lib/libdict/libdict.c @@ -398,8 +398,8 @@ int dict_enumerate(dict * d, int rank, char ** key, char ** val) return -1 ; } - while ((d->table[rank].key == NULL || d->table[rank].key == DUMMY_PTR) - && (rank < (int)d->size)) + while ((rank < (int)d->size) && + (d->table[rank].key == NULL || d->table[rank].key == DUMMY_PTR)) rank++; if (rank >= (int)d->size) {