mirror of
https://github.com/transmission/transmission
synced 2025-02-03 04:53:27 +00:00
don't crash when creating a single-file torrent of a zero-byte file. Reported by BentMyWookie.
This commit is contained in:
parent
d8a6dd1e28
commit
73af49bd08
2 changed files with 9 additions and 3 deletions
|
@ -65,12 +65,14 @@ progress_response_cb ( GtkDialog *d UNUSED, int response, gpointer user_data )
|
|||
static gboolean
|
||||
refresh_cb ( gpointer user_data )
|
||||
{
|
||||
int denom;
|
||||
char buf[1024];
|
||||
double fraction;
|
||||
MakeMetaUI * ui = (MakeMetaUI *) user_data;
|
||||
GtkProgressBar * p = GTK_PROGRESS_BAR( ui->progressbar );
|
||||
|
||||
fraction = (double)ui->builder->pieceIndex / ui->builder->pieceCount;
|
||||
denom = ui->builder->pieceCount ? ui->builder->pieceCount : 1;
|
||||
fraction = (double)ui->builder->pieceIndex / denom;
|
||||
gtk_progress_bar_set_fraction( p, fraction );
|
||||
g_snprintf( buf, sizeof(buf), "%s (%d%%)", ui->torrent_name, (int)(fraction*100 + 0.5));
|
||||
gtk_progress_bar_set_text( p, buf );
|
||||
|
|
|
@ -181,13 +181,17 @@ static uint8_t*
|
|||
getHashInfo ( tr_metainfo_builder_t * b )
|
||||
{
|
||||
int fileIndex = 0;
|
||||
uint8_t *ret = tr_new( uint8_t, SHA_DIGEST_LENGTH * b->pieceCount );
|
||||
uint8_t *ret = tr_new0( uint8_t, SHA_DIGEST_LENGTH * b->pieceCount );
|
||||
uint8_t *walk = ret;
|
||||
uint8_t *buf = tr_new( uint8_t, b->pieceSize );
|
||||
uint8_t *buf;
|
||||
uint64_t totalRemain;
|
||||
uint64_t off = 0;
|
||||
FILE * fp;
|
||||
|
||||
if( !b->totalSize )
|
||||
return ret;
|
||||
|
||||
buf = tr_new( uint8_t, b->pieceSize );
|
||||
b->pieceIndex = 0;
|
||||
totalRemain = b->totalSize;
|
||||
fp = fopen( b->files[fileIndex].filename, "rb" );
|
||||
|
|
Loading…
Reference in a new issue