From 4900febfd91ec310a80673783c2022a22c856a66 Mon Sep 17 00:00:00 2001 From: ngiddings Date: Tue, 13 Apr 2021 00:25:34 -0500 Subject: [PATCH] Fixed wraparound problem in compare_regions() --- src/memorymap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/memorymap.c b/src/memorymap.c index 543e89a..e484360 100644 --- a/src/memorymap.c +++ b/src/memorymap.c @@ -5,11 +5,13 @@ int compare_regions(struct memory_region_t *lhs, struct memory_region_t *rhs) { if(lhs->location == rhs->location) { - return lhs->size - rhs->size; + return lhs->size > rhs->size ? 1 + : (lhs->size == rhs->size ? 0 + : -1); } else { - return lhs->location - rhs->location; + return lhs->location > rhs->location ? 1 : -1; } }