Fix a bug in Mem_region_map_base::sub

Christian Ehrhardt Christian_Ehrhardt at genua.de
Tue May 3 14:17:39 CEST 2011


If two consecutive Mem_regions are contained in a range that is given
to Mem_region_map_base::sub(), the second region will not be removed.
The first region will be removed and the second region will be copied
to position "pos". The next loop iteration will then continue at pos+1
skipping the region just copied from pos+1 to pos by del().

diff --git a/src/kernel/fiasco/src/lib/libk/mem_region.cpp b/src/kernel/fiasco/src/lib/libk/mem_region.cpp
index 6c76df2..8475d3d 100644
--- a/src/kernel/fiasco/src/lib/libk/mem_region.cpp
+++ b/src/kernel/fiasco/src/lib/libk/mem_region.cpp
@@ -118,7 +118,10 @@ Mem_region_map_base::sub(Mem_region const &r)
       if (_r[pos].overlaps(r))
 	{
 	  if (r.contains(_r[pos]))
-	    del(pos, pos+1);
+	    {
+	      del(pos, pos+1);
+	      pos--;
+	    }
 	  else if (r.start <= _r[pos].start)
 	    _r[pos].start = r.end + 1;
 	  else if (r.end >= _r[pos].end)




More information about the l4-hackers mailing list