Changeset 2301


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?.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/makemeta-ui.c

    r2153 r2301  
    6666refresh_cb ( gpointer user_data )
    6767{
     68    int denom;
    6869    char buf[1024];
    6970    double fraction;
     
    7172    GtkProgressBar * p = GTK_PROGRESS_BAR( ui->progressbar );
    7273
    73     fraction = (double)ui->builder->pieceIndex / ui->builder->pieceCount;
     74    denom = ui->builder->pieceCount ? ui->builder->pieceCount : 1;
     75    fraction = (double)ui->builder->pieceIndex / denom;
    7476    gtk_progress_bar_set_fraction( p, fraction );
    7577    g_snprintf( buf, sizeof(buf), "%s (%d%%)", ui->torrent_name, (int)(fraction*100 + 0.5));
  • 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.