Changeset 14151


Ignore:
Timestamp:
Jul 29, 2013, 4:19:15 AM (9 years ago)
Author:
jordan
Message:

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

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bitfield.c

    r13655 r14151  
    180180  const size_t n = get_bytes_needed (bit_count);
    181181
    182   memset (array, val, n-1);
    183 
    184   array[n-1] = val << (n*8 - bit_count);
     182  if (n > 0)
     183    {
     184      memset (array, val, n-1);
     185
     186      array[n-1] = val << (n*8 - bit_count);
     187    }
    185188}
    186189
  • trunk/libtransmission/completion.h

    r13625 r14151  
    9292static inline bool tr_cpHasAll (const tr_completion * cp)
    9393{
    94     return tr_bitfieldHasAll (&cp->blockBitfield);
     94    return tr_torrentHasMetadata (cp->tor)
     95        && tr_bitfieldHasAll (&cp->blockBitfield);
    9596}
    9697
    9798static inline bool tr_cpHasNone (const tr_completion * cp)
    9899{
    99     return tr_bitfieldHasNone (&cp->blockBitfield);
     100    return !tr_torrentHasMetadata (cp->tor)
     101        || tr_bitfieldHasNone (&cp->blockBitfield);
    100102}
    101103
Note: See TracChangeset for help on using the changeset viewer.