From fa54f390aef977b6153b5d2dfc6f8c4374ac76d5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 17 Nov 2008 05:05:11 +0000 Subject: [PATCH] #1476: crash on exit when stats window is open --- libtransmission/stats.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libtransmission/stats.c b/libtransmission/stats.c index 1cc03760a..7c41b984a 100644 --- a/libtransmission/stats.c +++ b/libtransmission/stats.c @@ -10,8 +10,6 @@ * $Id$ */ -#include - #include "transmission.h" #include "bencode.h" #include "platform.h" /* tr_sessionGetConfigDir() */ @@ -131,7 +129,7 @@ tr_statsClose( tr_handle * handle ) static struct tr_stats_handle * getStats( const tr_handle * handle ) { - return handle->sessionStats; + return handle ? handle->sessionStats : NULL; } /*** @@ -163,11 +161,12 @@ tr_sessionGetStats( const tr_handle * handle, tr_session_stats * setme ) { const struct tr_stats_handle * stats = getStats( handle ); - - assert( stats ); - *setme = stats->single; - setme->secondsActive = time( NULL ) - stats->startTime; - updateRatio( setme ); + if( stats ) + { + *setme = stats->single; + setme->secondsActive = time( NULL ) - stats->startTime; + updateRatio( setme ); + } } void @@ -175,11 +174,13 @@ tr_sessionGetCumulativeStats( const tr_handle * handle, tr_session_stats * setme ) { const struct tr_stats_handle * stats = getStats( handle ); - tr_session_stats current; + tr_session_stats current; - assert( stats ); - tr_sessionGetStats( handle, ¤t ); - addStats( setme, &stats->old, ¤t ); + if( stats ) + { + tr_sessionGetStats( handle, ¤t ); + addStats( setme, &stats->old, ¤t ); + } } void