[RTL]
authorThomas Faber <thomas.faber@reactos.org>
Mon, 31 Mar 2014 19:57:42 +0000 (19:57 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Mon, 31 Mar 2014 19:57:42 +0000 (19:57 +0000)
- Fix buffer overrun in RtlNumberOfSetBits

svn path=/trunk/; revision=62591

reactos/lib/rtl/bitmap.c

index b009355..6ceddf9 100644 (file)
@@ -467,8 +467,11 @@ RtlNumberOfSetBits(
         BitCount += BitCountTable[*Byte++];
     }
 
-    Shift = 8 - (BitMapHeader->SizeOfBitMap & 7);
-    BitCount += BitCountTable[((*Byte) << Shift) & 0xFF];
+    if (BitMapHeader->SizeOfBitMap & 7)
+    {
+        Shift = 8 - (BitMapHeader->SizeOfBitMap & 7);
+        BitCount += BitCountTable[((*Byte) << Shift) & 0xFF];
+    }
 
     return BitCount;
 }