mirror of
https://github.com/transmission/transmission
synced 2024-12-31 20:16:57 +00:00
(gtk) fix potential invalid memory read on shutdown
This commit is contained in:
parent
101307ddff
commit
3e88159e9f
4 changed files with 24 additions and 7 deletions
|
@ -550,7 +550,7 @@ quitThreadFunc( gpointer gdata )
|
|||
{
|
||||
struct cbdata * cbdata = gdata;
|
||||
|
||||
tr_close( tr_core_handle( cbdata->core ) );
|
||||
tr_core_close( cbdata->core );
|
||||
|
||||
/* shutdown the gui */
|
||||
if( cbdata->prefs )
|
||||
|
|
|
@ -551,6 +551,17 @@ tr_core_new( void )
|
|||
return core;
|
||||
}
|
||||
|
||||
void
|
||||
tr_core_close( TrCore * core )
|
||||
{
|
||||
tr_handle * handle = tr_core_handle( core );
|
||||
if( handle )
|
||||
{
|
||||
core->priv->handle = NULL;
|
||||
tr_close( handle );
|
||||
}
|
||||
}
|
||||
|
||||
GtkTreeModel *
|
||||
tr_core_model( TrCore * core )
|
||||
{
|
||||
|
@ -595,6 +606,7 @@ tr_core_get_stats( const TrCore * core,
|
|||
tr_torrentRates( core->priv->handle,
|
||||
&setme->clientDownloadSpeed,
|
||||
&setme->clientUploadSpeed );
|
||||
|
||||
gtk_tree_model_foreach( core->priv->model,
|
||||
statsForeach,
|
||||
setme );
|
||||
|
|
|
@ -91,6 +91,8 @@ GType tr_core_get_type( void );
|
|||
|
||||
TrCore * tr_core_new( void );
|
||||
|
||||
void tr_core_close( TrCore* );
|
||||
|
||||
/* Return the model used without incrementing the reference count */
|
||||
GtkTreeModel * tr_core_model( TrCore * self );
|
||||
|
||||
|
|
|
@ -362,14 +362,17 @@ tr_getGlobalPeerLimit( const tr_handle * handle UNUSED )
|
|||
void
|
||||
tr_torrentRates( tr_handle * h, float * toClient, float * toPeer )
|
||||
{
|
||||
tr_globalLock( h );
|
||||
if( h )
|
||||
{
|
||||
tr_globalLock( h );
|
||||
|
||||
if( toClient )
|
||||
*toClient = tr_rcRate( h->download );
|
||||
if( toPeer )
|
||||
*toPeer = tr_rcRate( h->upload );
|
||||
if( toClient )
|
||||
*toClient = tr_rcRate( h->download );
|
||||
if( toPeer )
|
||||
*toPeer = tr_rcRate( h->upload );
|
||||
|
||||
tr_globalUnlock( h );
|
||||
tr_globalUnlock( h );
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue