Fix a bug in RtlNumberOfSetBits

svn path=/trunk/; revision=56793
This commit is contained in:
Timo Kreuzer 2012-06-24 12:51:27 +00:00
parent 8e9219216a
commit b6b380a67b

View file

@ -410,16 +410,18 @@ RtlNumberOfSetBits(
IN PRTL_BITMAP BitMapHeader)
{
PUCHAR Byte, MaxByte;
ULONG BitCount = 0;
ULONG BitCount = 0, Shift;
Byte = (PUCHAR)BitMapHeader->Buffer;
MaxByte = Byte + (BitMapHeader->SizeOfBitMap + 7) / 8;
MaxByte = Byte + BitMapHeader->SizeOfBitMap / 8;
do
while (Byte < MaxByte);
{
BitCount += BitCountTable[*Byte++];
}
while (Byte <= MaxByte);
Shift = 8 - (BitMapHeader->SizeOfBitMap & 7);
BitCount += BitCountTable[(*Byte) << Shift];
return BitCount;
}