From b7eda7987915461a8480a4e17376e163dcbdd970 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Tue, 8 Apr 2014 21:04:47 +0000 Subject: [PATCH] [RTL] - Fix apitest crashes in RtlFindClearBits/RtlFindSetBits svn path=/trunk/; revision=62691 --- reactos/lib/rtl/bitmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reactos/lib/rtl/bitmap.c b/reactos/lib/rtl/bitmap.c index 6ceddf927ee..350e182191c 100644 --- a/reactos/lib/rtl/bitmap.c +++ b/reactos/lib/rtl/bitmap.c @@ -101,6 +101,11 @@ RtlpGetLengthOfRunClear( BITMAP_INDEX Value, BitPos, Length; PBITMAP_BUFFER Buffer, MaxBuffer; + /* If we are already at the end, the length of the run is zero */ + ASSERT(StartingIndex <= BitMapHeader->SizeOfBitMap); + if (StartingIndex >= BitMapHeader->SizeOfBitMap) + return 0; + /* Calculate positions */ Buffer = BitMapHeader->Buffer + StartingIndex / _BITCOUNT; BitPos = StartingIndex & (_BITCOUNT - 1); @@ -150,6 +155,11 @@ RtlpGetLengthOfRunSet( BITMAP_INDEX InvValue, BitPos, Length; PBITMAP_BUFFER Buffer, MaxBuffer; + /* If we are already at the end, the length of the run is zero */ + ASSERT(StartingIndex <= BitMapHeader->SizeOfBitMap); + if (StartingIndex >= BitMapHeader->SizeOfBitMap) + return 0; + /* Calculate positions */ Buffer = BitMapHeader->Buffer + StartingIndex / _BITCOUNT; BitPos = StartingIndex & (_BITCOUNT - 1);