1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-16 16:55:36 +00:00

#853: transmission-(daemon|gtk) segfault when querying status

This commit is contained in:
Charles Kerr 2008-04-10 19:02:24 +00:00
parent afb5738b98
commit 5619eae447
6 changed files with 32 additions and 35 deletions

View file

@ -486,8 +486,7 @@ addmsg1( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
tor = torrent_add_file( file->val.s.s, NULL, -1 );
if( TORRENT_ID_VALID( tor ) )
{
const tr_info * inf = torrent_info( tor );
if( 0 > ipc_addinfo( added, tor, inf, 0 ) )
if( 0 > ipc_addinfo( added, tor, torrent_handle( tor ), 0 ) )
{
errnomsg( "failed to build message" );
tr_bencFree( &pk );
@ -544,7 +543,6 @@ addmsg2( enum ipc_msg id UNUSED, benc_val_t * dict, int64_t tag, void * arg )
if( TORRENT_ID_VALID( tor ) )
{
const tr_info * inf;
val = ipc_initval( client->ipc, IPC_MSG_INFO, tag, &pk, TYPE_LIST );
if( NULL == val )
{
@ -552,8 +550,7 @@ addmsg2( enum ipc_msg id UNUSED, benc_val_t * dict, int64_t tag, void * arg )
byebye( client->ev, EVBUFFER_EOF, NULL );
return;
}
inf = torrent_info( tor );
if( 0 > ipc_addinfo( val, tor, inf, 0 ) )
if( 0 > ipc_addinfo( val, tor, torrent_handle( tor ), 0 ) )
{
errnomsg( "failed to build message" );
tr_bencFree( &pk );
@ -767,15 +764,15 @@ infomsg( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
int
addinfo( benc_val_t * list, int id, int types )
{
const tr_info * inf = torrent_info( id );
return inf ? ipc_addinfo( list, id, inf, types ) : 0;
tr_torrent * tor = torrent_handle( id );
return tor ? ipc_addinfo( list, id, tor, types ) : 0;
}
int
addstat( benc_val_t * list, int id, int types )
{
const tr_stat * st = torrent_stat( id );
return st ? ipc_addstat( list, id, st, types ) : 0;
tr_torrent * tor = torrent_handle( id );
return tor ? ipc_addstat( list, id, tor, types ) : 0;
}
void
@ -878,7 +875,6 @@ lookmsg( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
for( ii = 0; val->val.l.count > ii; ii++ )
{
const tr_info * inf;
hash = &val->val.l.vals[ii];
if( !tr_bencIsString(hash) || SHA_DIGEST_LENGTH * 2 != hash->val.s.i )
{
@ -891,9 +887,7 @@ lookmsg( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
{
continue;
}
inf = torrent_info( found );
assert( NULL != inf );
if( 0 > ipc_addinfo( pkinf, found, inf, IPC_INF_HASH ) )
if( 0 > ipc_addinfo( pkinf, found, torrent_handle( found ), IPC_INF_HASH ) )
{
errnomsg( "failed to build message" );
tr_bencFree( &pk );

View file

@ -230,18 +230,23 @@ torrent_remove( int id )
}
}
tr_torrent *
torrent_handle( int id )
{
const struct tor * tor = idlookup( id );
return tor ? tor->tor : NULL;
}
const tr_info *
torrent_info( int id )
{
const struct tor * tor = idlookup( id );
return tor ? tr_torrentInfo( tor->tor ) : NULL;
return tr_torrentInfo( torrent_handle( id ) );
}
const tr_stat *
torrent_stat( int id )
{
struct tor * tor = idlookup( id );
return tor ? tr_torrentStat( tor->tor ) : NULL;
return tr_torrentStat( torrent_handle( id ) );
}
static struct tor *

View file

@ -38,8 +38,9 @@ void torrent_start ( int );
void torrent_stop ( int );
void torrent_verify ( int );
void torrent_remove ( int );
const tr_info * torrent_info ( int );
const tr_stat * torrent_stat ( int );
tr_torrent * torrent_handle ( int );
const tr_info * torrent_info ( int );
const tr_stat * torrent_stat ( int );
int torrent_lookup ( const uint8_t * );
void * torrent_iter ( void *, int * );

View file

@ -618,19 +618,15 @@ findtorid( TrCore * core, int id, GtkTreeIter * iter )
}
static int
addinfo( TrTorrent * tor, enum ipc_msg msgid, int torid, int types,
addinfo( TrTorrent * gtor, enum ipc_msg msgid, int torid, int types,
tr_benc * val )
{
tr_torrent * tor = tr_torrent_handle( gtor );
if( IPC_MSG_INFO == msgid )
{
const tr_info * inf = tr_torrent_info( tor );
return ipc_addinfo( val, torid, inf, types );
}
return ipc_addinfo( val, torid, tor, types );
else
{
const tr_stat * st = tr_torrent_stat( tor );
return ipc_addstat( val, torid, st, types );
}
return ipc_addstat( val, torid, tor, types );
}
static void
@ -793,7 +789,6 @@ smsg_look( enum ipc_msg id UNUSED, tr_benc * val, int64_t tag,
tr_benc packet, * pkval, * hash;
int ii, torid;
TrTorrent * tor;
const tr_info * inf;
uint8_t * buf;
size_t size;
@ -819,8 +814,7 @@ smsg_look( enum ipc_msg id UNUSED, tr_benc * val, int64_t tag,
{
continue;
}
inf = tr_torrent_info( tor );
if( 0 > ipc_addinfo( pkval, torid, inf, IPC_INF_HASH ) )
if( 0 > ipc_addinfo( pkval, torid, tr_torrent_handle( tor ), IPC_INF_HASH ) )
{
tr_bencFree( &packet );
simpleresp( con, tag, IPC_MSG_FAIL );

View file

@ -552,12 +552,13 @@ filltracker( tr_benc * val, const tr_tracker_info * tk )
int
ipc_addinfo( tr_benc * list,
int torrent_id,
const tr_info * inf,
tr_torrent * tor,
int types )
{
tr_benc * dict;
int ii, jj, kk;
tr_file_index_t ff;
const tr_info * inf = tr_torrentInfo( tor );
/* always send torrent id */
types |= IPC_INF_ID;

View file

@ -170,11 +170,13 @@ uint8_t * ipc_createInfoRequest( const struct ipc_info * session,
int types,
const int * ids );
int ipc_addinfo ( struct tr_benc *, int,
const struct tr_info *, int );
struct tr_torrent;
int ipc_addinfo ( struct tr_benc * appendme_list,
int torrent_id,
struct tr_torrent * tor,
int info_types );
int ipc_addstat ( struct tr_benc * appendme_list,
int torrent_id,
struct tr_torrent * tor,