From 02d6feb9b9df25106d11f50f15ec9f502cde6ae6 Mon Sep 17 00:00:00 2001 From: NRK Date: Sat, 25 Dec 2021 12:18:47 +0600 Subject: [PATCH] check bound before making access --- src/nnn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nnn.c b/src/nnn.c index 402f67ec..a0fafe98 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -3803,7 +3803,7 @@ static char *get_kv_val(kv *kvarr, char *buf, int key, uchar_t max, uchar_t id) if (!kvarr) return NULL; - for (int r = 0; kvarr[r].key && r < max; ++r) { + for (int r = 0; r < max && kvarr[r].key; ++r) { if (kvarr[r].key == key) { /* Do not allocate new memory for plugin */ if (id == NNN_PLUG) @@ -3827,7 +3827,7 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id) if (id != NNN_ORDER) /* For now this function supports only order string */ return -1; - for (int r = 0; kvarr[r].key && r < max; ++r) { + for (int r = 0; r < max && kvarr[r].key; ++r) { if (xstrcmp((orderstr + kvarr[r].off), val) == 0) return kvarr[r].key; }