From 2155df7d6f952d9ec94233ff7bddf61aa715adff Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 6 Jul 2017 10:26:14 +0200 Subject: [PATCH] Fix bug detected by previous test. --- m-array.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/m-array.h b/m-array.h index d96c058d..dcb9e200 100644 --- a/m-array.h +++ b/m-array.h @@ -539,8 +539,9 @@ M_C3(array_, name, _last_p)(const array_it_t it) \ { \ assert(it != NULL && it->array != NULL); \ - /* NOTE: Case index=0 & size=0 ==> true since unsigned type */ \ - return (it->index) >= it->array->size-1; \ + /* NOTE: Can not compute 'size-1' due to potential overflow \ + if size was 0 */ \ + return it->index + 1 >= it->array->size; \ } \ \ static inline bool \