mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
(trunk libT) #5444 'underflow in bitfield.c's set_all_true()' -- fixed
This commit is contained in:
parent
1c79173459
commit
a8f965b489
2 changed files with 9 additions and 4 deletions
|
@ -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);
|
||||
|
||||
memset (array, val, n-1);
|
||||
if (n > 0)
|
||||
{
|
||||
memset (array, val, n-1);
|
||||
|
||||
array[n-1] = val << (n*8 - bit_count);
|
||||
array[n-1] = val << (n*8 - bit_count);
|
||||
}
|
||||
}
|
||||
|
||||
void*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue