Author: tfaber
Date: Tue Apr  8 21:04:47 2014
New Revision: 62691

URL: http://svn.reactos.org/svn/reactos?rev=62691&view=rev
Log:
[RTL]
- Fix apitest crashes in RtlFindClearBits/RtlFindSetBits

Modified:
    trunk/reactos/lib/rtl/bitmap.c

Modified: trunk/reactos/lib/rtl/bitmap.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/bitmap.c?rev=62691&r1=62690&r2=62691&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/bitmap.c      [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/bitmap.c      [iso-8859-1] Tue Apr  8 21:04:47 2014
@@ -101,6 +101,11 @@
     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);
@@ -149,6 +154,11 @@
 {
     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;


Reply via email to