Skip to content

Commit

Permalink
fix relying on integer underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lvandeve committed May 3, 2016
1 parent c6cf08b commit db9cc96
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lodepng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2385,9 +2385,10 @@ static unsigned readBitsFromReversedStream(size_t* bitpointer, const unsigned ch
{
unsigned result = 0;
size_t i;
for(i = nbits - 1; i < nbits; --i)
for(i = 0 ; i < nbits; ++i)
{
result += (unsigned)readBitFromReversedStream(bitpointer, bitstream) << i;
result <<= 1;
result |= (unsigned)readBitFromReversedStream(bitpointer, bitstream);
}
return result;
}
Expand Down

0 comments on commit db9cc96

Please sign in to comment.