mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
(trunk T) #3404 "crash when creating a .torrent containing empty content" -- fixed
This commit is contained in:
parent
0b42fcf730
commit
b5e93da8f4
3 changed files with 17 additions and 7 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <libtransmission/transmission.h>
|
||||
#include <libtransmission/makemeta.h>
|
||||
#include <libtransmission/utils.h> /* tr_formatter_mem_B() */
|
||||
|
||||
#include "conf.h"
|
||||
#include "hig.h"
|
||||
|
@ -67,8 +68,8 @@ onProgressDialogRefresh( gpointer data )
|
|||
const tr_metainfo_builder * b = ui->builder;
|
||||
GtkDialog * d = GTK_DIALOG( ui->progress_dialog );
|
||||
GtkProgressBar * p = GTK_PROGRESS_BAR( ui->progress_bar );
|
||||
const double fraction = (double)b->pieceIndex / b->pieceCount;
|
||||
char * base = g_path_get_basename( b->top );
|
||||
const double fraction = b->pieceCount ? ((double)b->pieceIndex / b->pieceCount) : 0;
|
||||
char * base = g_path_get_basename( b->top );
|
||||
|
||||
/* progress label */
|
||||
if( !b->isDone )
|
||||
|
@ -300,7 +301,8 @@ updatePiecesLabel( MakeMetaUI * ui )
|
|||
builder->fileCount ),
|
||||
buf, builder->fileCount );
|
||||
g_string_append( gstr, "; " );
|
||||
tr_strlsize( buf, builder->pieceSize, sizeof( buf ) );
|
||||
|
||||
tr_formatter_mem_B( buf, builder->pieceSize, sizeof( buf ) );
|
||||
g_string_append_printf( gstr, ngettext( "%1$'d Piece @ %2$s",
|
||||
"%1$'d Pieces @ %2$s",
|
||||
builder->pieceCount ),
|
||||
|
|
|
@ -388,6 +388,15 @@ tr_realMakeMetaInfo( tr_metainfo_builder * builder )
|
|||
|
||||
tr_bencInitDict( &top, 6 );
|
||||
|
||||
if( !builder->fileCount || !builder->totalSize ||
|
||||
!builder->pieceSize || !builder->pieceCount )
|
||||
{
|
||||
builder->errfile[0] = '\0';
|
||||
builder->my_errno = ENOENT;
|
||||
builder->result = TR_MAKEMETA_IO_READ;
|
||||
builder->isDone = TRUE;
|
||||
}
|
||||
|
||||
if( !builder->result && builder->trackerCount )
|
||||
{
|
||||
int prevTier = -1;
|
||||
|
@ -514,8 +523,7 @@ tr_makeMetaInfo( tr_metainfo_builder * builder,
|
|||
builder->pieceIndex = 0;
|
||||
builder->trackerCount = trackerCount;
|
||||
builder->trackers = tr_new0( tr_tracker_info, builder->trackerCount );
|
||||
for( i = 0; i < builder->trackerCount; ++i )
|
||||
{
|
||||
for( i = 0; i < builder->trackerCount; ++i ) {
|
||||
builder->trackers[i].tier = trackers[i].tier;
|
||||
builder->trackers[i].announce = tr_strdup( trackers[i].announce );
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ typedef enum
|
|||
TR_MAKEMETA_OK,
|
||||
TR_MAKEMETA_URL,
|
||||
TR_MAKEMETA_CANCELLED,
|
||||
TR_MAKEMETA_IO_READ, /* see builder.errfile, builder.errno */
|
||||
TR_MAKEMETA_IO_WRITE /* see builder.errfile, builder.errno */
|
||||
TR_MAKEMETA_IO_READ, /* see builder.errfile, builder.my_errno */
|
||||
TR_MAKEMETA_IO_WRITE /* see builder.errfile, builder.my_errno */
|
||||
}
|
||||
tr_metainfo_builder_err;
|
||||
|
||||
|
|
Loading…
Reference in a new issue