1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(trunk libT) #5444 'underflow in bitfield.c's set_all_true()' -- fixed

This commit is contained in:
Jordan Lee 2013-07-29 04:19:15 +00:00
parent 1c79173459
commit a8f965b489
2 changed files with 9 additions and 4 deletions

View file

@ -179,9 +179,12 @@ set_all_true (uint8_t * array, size_t bit_count)
const uint8_t val = 0xFF;
const size_t n = get_bytes_needed (bit_count);
if (n > 0)
{
memset (array, val, n-1);
array[n-1] = val << (n*8 - bit_count);
}
}
void*

View file

@ -91,12 +91,14 @@ tr_cpHaveTotal (const tr_completion * cp)
static inline bool tr_cpHasAll (const tr_completion * cp)
{
return tr_bitfieldHasAll (&cp->blockBitfield);
return tr_torrentHasMetadata (cp->tor)
&& tr_bitfieldHasAll (&cp->blockBitfield);
}
static inline bool tr_cpHasNone (const tr_completion * cp)
{
return tr_bitfieldHasNone (&cp->blockBitfield);
return !tr_torrentHasMetadata (cp->tor)
|| tr_bitfieldHasNone (&cp->blockBitfield);
}
/**