1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-03 13:35:36 +00:00

(gtk) fix potential invalid memory read on shutdown

This commit is contained in:
Charles Kerr 2008-04-17 20:35:18 +00:00
parent 101307ddff
commit 3e88159e9f
4 changed files with 24 additions and 7 deletions

View file

@ -550,7 +550,7 @@ quitThreadFunc( gpointer gdata )
{ {
struct cbdata * cbdata = gdata; struct cbdata * cbdata = gdata;
tr_close( tr_core_handle( cbdata->core ) ); tr_core_close( cbdata->core );
/* shutdown the gui */ /* shutdown the gui */
if( cbdata->prefs ) if( cbdata->prefs )

View file

@ -551,6 +551,17 @@ tr_core_new( void )
return core; 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 * GtkTreeModel *
tr_core_model( TrCore * core ) tr_core_model( TrCore * core )
{ {
@ -595,6 +606,7 @@ tr_core_get_stats( const TrCore * core,
tr_torrentRates( core->priv->handle, tr_torrentRates( core->priv->handle,
&setme->clientDownloadSpeed, &setme->clientDownloadSpeed,
&setme->clientUploadSpeed ); &setme->clientUploadSpeed );
gtk_tree_model_foreach( core->priv->model, gtk_tree_model_foreach( core->priv->model,
statsForeach, statsForeach,
setme ); setme );

View file

@ -91,6 +91,8 @@ GType tr_core_get_type( void );
TrCore * tr_core_new( void ); TrCore * tr_core_new( void );
void tr_core_close( TrCore* );
/* Return the model used without incrementing the reference count */ /* Return the model used without incrementing the reference count */
GtkTreeModel * tr_core_model( TrCore * self ); GtkTreeModel * tr_core_model( TrCore * self );

View file

@ -362,14 +362,17 @@ tr_getGlobalPeerLimit( const tr_handle * handle UNUSED )
void void
tr_torrentRates( tr_handle * h, float * toClient, float * toPeer ) tr_torrentRates( tr_handle * h, float * toClient, float * toPeer )
{ {
tr_globalLock( h ); if( h )
{
tr_globalLock( h );
if( toClient ) if( toClient )
*toClient = tr_rcRate( h->download ); *toClient = tr_rcRate( h->download );
if( toPeer ) if( toPeer )
*toPeer = tr_rcRate( h->upload ); *toPeer = tr_rcRate( h->upload );
tr_globalUnlock( h ); tr_globalUnlock( h );
}
} }
int int