From 2473ca92aaa49ff2a70c9b931b5a3068d65844f7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 24 Aug 2012 13:54:04 -0700 Subject: [PATCH] retrace: Fix off-by-one error in detection of intersecting regions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The upperBound functions returns the first region beyond the region containing the given address. So, to correctly use it here, we must give it the last valid address of the current range, which is just less than (address + size). Signed-off-by: José Fonseca --- retrace/retrace_swizzle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retrace/retrace_swizzle.cpp b/retrace/retrace_swizzle.cpp index 52d1d74..693fdfe 100644 --- a/retrace/retrace_swizzle.cpp +++ b/retrace/retrace_swizzle.cpp @@ -108,7 +108,7 @@ addRegion(unsigned long long address, void *buffer, unsigned long long size) #ifndef NDEBUG RegionMap::iterator start = lowerBound(address); - RegionMap::iterator stop = upperBound(address + size); + RegionMap::iterator stop = upperBound(address + size - 1); if (0) { // Forget all regions that intersect this new one. regionMap.erase(start, stop); -- 2.43.0