Ignore:
Timestamp:
Jul 6, 2007, 6:24:54 PM (15 years ago)
Author:
charles
Message:

don't crash when creating a single-file torrent of a zero-byte file. Reported by BentMyWookie?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/makemeta.c

    r2268 r2301  
    182182{
    183183    int fileIndex = 0;
    184     uint8_t *ret = tr_new( uint8_t, SHA_DIGEST_LENGTH * b->pieceCount );
     184    uint8_t *ret = tr_new0( uint8_t, SHA_DIGEST_LENGTH * b->pieceCount );
    185185    uint8_t *walk = ret;
    186     uint8_t *buf = tr_new( uint8_t, b->pieceSize );
     186    uint8_t *buf;
    187187    uint64_t totalRemain;
    188188    uint64_t off = 0;
    189189    FILE * fp;
    190190
     191    if( !b->totalSize )
     192        return ret;
     193
     194    buf = tr_new( uint8_t, b->pieceSize );
    191195    b->pieceIndex = 0;
    192196    totalRemain = b->totalSize;
Note: See TracChangeset for help on using the changeset viewer.