From 8a1f24ca548002064000c7829de7174f7cbae5f2 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 27 Sep 2017 22:57:08 +0200 Subject: [PATCH] Fix issue detected by address sanitizer (Read beyond and below the table allocation). --- m-dict.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/m-dict.h b/m-dict.h index d23cf9e1..fd29fa4d 100644 --- a/m-dict.h +++ b/m-dict.h @@ -1147,14 +1147,14 @@ typedef enum { assert (it != NULL); \ DICTI_OA_CONTRACT (it->dict); \ size_t i = it->index + 1; \ - while ((oor_equal_p (it->dict->data[i].key, DICTI_OA_EMPTY) \ - || oor_equal_p (it->dict->data[i].key, DICTI_OA_DELETED)) \ - && i <= it->dict->mask) { \ + while (i <= it->dict->mask && \ + (oor_equal_p (it->dict->data[i].key, DICTI_OA_EMPTY) \ + || oor_equal_p (it->dict->data[i].key, DICTI_OA_DELETED))) { \ i++; \ } \ it->index = i; \ } \ - \ + \ static inline void \ M_C(name, _previous)(dict_it_t it) \ { \ @@ -1162,9 +1162,9 @@ typedef enum { DICTI_OA_CONTRACT (it->dict); \ /* if index was 0, the operation will overflow, and stops the loop */ \ size_t i = it->index - 1; \ - while ((oor_equal_p (it->dict->data[i].key, DICTI_OA_EMPTY) \ - || oor_equal_p (it->dict->data[i].key, DICTI_OA_DELETED)) \ - && i <= it->dict->mask) { \ + while (i <= it->dict->mask && \ + (oor_equal_p (it->dict->data[i].key, DICTI_OA_EMPTY) \ + || oor_equal_p (it->dict->data[i].key, DICTI_OA_DELETED))) { \ i--; \ } \ it->index = i; \