Changeset 10970


Ignore:
Timestamp:
Jul 7, 2010, 10:50:18 PM (12 years ago)
Author:
charles
Message:

(trunk T) #3404 "crash when creating a .torrent containing empty content" -- fixed

Location:
trunk
Files:
3 edited

Legend:

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

    r10340 r10970  
    1818#include <libtransmission/transmission.h>
    1919#include <libtransmission/makemeta.h>
     20#include <libtransmission/utils.h> /* tr_formatter_mem_B() */
    2021
    2122#include "conf.h"
     
    6869    GtkDialog * d = GTK_DIALOG( ui->progress_dialog );
    6970    GtkProgressBar * p = GTK_PROGRESS_BAR( ui->progress_bar );
    70     const double fraction = (double)b->pieceIndex / b->pieceCount;
    71         char * base = g_path_get_basename( b->top );
     71    const double fraction = b->pieceCount ? ((double)b->pieceIndex / b->pieceCount) : 0;
     72    char * base = g_path_get_basename( b->top );
    7273
    7374    /* progress label */
     
    301302                                buf, builder->fileCount );
    302303        g_string_append( gstr, "; " );
    303         tr_strlsize( buf, builder->pieceSize, sizeof( buf ) );
     304 
     305        tr_formatter_mem_B( buf, builder->pieceSize, sizeof( buf ) );
    304306        g_string_append_printf( gstr, ngettext( "%1$'d Piece @ %2$s",
    305307                                                "%1$'d Pieces @ %2$s",
  • trunk/libtransmission/makemeta.c

    r10920 r10970  
    389389    tr_bencInitDict( &top, 6 );
    390390
     391    if( !builder->fileCount || !builder->totalSize ||
     392        !builder->pieceSize || !builder->pieceCount )
     393    {
     394        builder->errfile[0] = '\0';
     395        builder->my_errno = ENOENT;
     396        builder->result = TR_MAKEMETA_IO_READ;
     397        builder->isDone = TRUE;
     398    }
     399
    391400    if( !builder->result && builder->trackerCount )
    392401    {
     
    515524    builder->trackerCount = trackerCount;
    516525    builder->trackers = tr_new0( tr_tracker_info, builder->trackerCount );
    517     for( i = 0; i < builder->trackerCount; ++i )
    518     {
     526    for( i = 0; i < builder->trackerCount; ++i ) {
    519527        builder->trackers[i].tier = trackers[i].tier;
    520528        builder->trackers[i].announce = tr_strdup( trackers[i].announce );
  • trunk/libtransmission/makemeta.h

    r9868 r10970  
    3030    TR_MAKEMETA_URL,
    3131    TR_MAKEMETA_CANCELLED,
    32     TR_MAKEMETA_IO_READ,   /* see builder.errfile, builder.errno */
    33     TR_MAKEMETA_IO_WRITE   /* see builder.errfile, builder.errno */
     32    TR_MAKEMETA_IO_READ,   /* see builder.errfile, builder.my_errno */
     33    TR_MAKEMETA_IO_WRITE   /* see builder.errfile, builder.my_errno */
    3434}
    3535tr_metainfo_builder_err;
Note: See TracChangeset for help on using the changeset viewer.