fix off-by-one error in stream_copyBits that seems to have been

responsible for HASH_STREAM not working.
This commit is contained in:
Eric House 2012-05-24 22:16:22 -07:00
parent fd7a25ba3c
commit 9354e0e0cd

View file

@ -178,14 +178,10 @@ mem_stream_copyBits( const XWStreamCtxt* p_sctx, XWStreamPos XP_UNUSED(startPos)
{
MemStreamCtxt* stream = (MemStreamCtxt*)p_sctx;
XP_U16 len = BYTE_PART(endPos);
XP_Bool hasBits = 0 != BIT_PART(endPos);
if ( hasBits ) {
++len;
}
if ( !!buf && len <= *lenp ) {
XP_ASSERT( len <= stream->nBytesAllocated );
XP_MEMCPY( buf, stream->buf, len );
if ( hasBits ) {
if ( 0 != BIT_PART(endPos) ) {
buf[len-1] &= 1 << BIT_PART(endPos);
}
}