Changeset 3285


Ignore:
Timestamp:
Oct 4, 2007, 8:31:19 PM (15 years ago)
Author:
charles
Message:

fix the crash reported by Waldorf and John_Clay

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r3272 r3285  
    577577    uint8_t reserved[HANDSHAKE_FLAGS_LEN];
    578578    uint8_t hash[SHA_DIGEST_LENGTH];
     579    char * client;
    579580
    580581/* FIXME: use  readHandshake here */
     
    667668    tr_peerIoSetPeersId( handshake->io, handshake->peer_id );
    668669    handshake->havePeerID = TRUE;
    669     dbgmsg( handshake, "peer-id is [%s]", tr_clientForId(handshake->peer_id) );
     670    client = tr_clientForId( handshake->peer_id );
     671    dbgmsg( handshake, "peer-id is [%s]", client );
     672    tr_free( client );
    670673    if( !memcmp( handshake->peer_id, getPeerId(), PEER_ID_LEN ) ) {
    671674        dbgmsg( handshake, "streuth!  we've connected to ourselves." );
  • trunk/libtransmission/peer-mgr.c

    r3280 r3285  
    405405    tr_ptrArrayFree( t->pool, (PtrArrayForeachFunc)tr_free );
    406406    tr_ptrArrayFree( t->outgoingHandshakes, NULL );
     407    tr_ptrArrayFree( t->peers, NULL );
    407408
    408409    tr_free( t );
  • trunk/libtransmission/tracker.c

    r3284 r3285  
    738738torrentIsRunning( const Torrent * tor )
    739739{
    740     return ( tor != NULL )
    741         && ( tor->lastRequest != NULL )
    742         && ( strcmp( tor->lastRequest, "stopped" ) );
     740    return tor && tor->isRunning;
    743741}
    744742
     
    841839static int onReannounceNow( void * vtor );
    842840
    843 static void
    844 onTrackerResponse( struct evhttp_request * req, void * vtor )
     841struct response_user_data
     842{
     843    tr_handle * handle;
     844    uint8_t hash[SHA_DIGEST_LENGTH];
     845};
     846
     847static struct response_user_data*
     848onTrackerResponseDataNew( Torrent * tor )
     849{
     850    struct response_user_data * data = tr_new( struct response_user_data, 1 );
     851    data->handle = tor->tracker->handle;
     852    memcpy( data->hash, tor->hash, SHA_DIGEST_LENGTH );
     853    return data;
     854}
     855
     856static void
     857onTrackerResponse( struct evhttp_request * req, void * vdata )
    845858{
    846859    char * errmsg;
    847     Torrent * tor = (Torrent *) vtor;
    848     const int isStopped = !torrentIsRunning( tor );
     860    Torrent * tor;
     861    int isStopped;
    849862    int reannounceInterval;
     863    struct response_user_data * data;
     864    tr_torrent * t;
     865
     866    data = vdata;
     867    t = tr_torrentFindFromHash( data->handle, data->hash );
     868    tr_free( data );
     869    if( t == NULL ) /* torrent has been closed */
     870        return;
     871
     872    tor = t->tracker;
     873    isStopped = !torrentIsRunning( tor );
    850874
    851875    tr_inf( "Torrent \"%s\" tracker response: %s",
     
    9771001        t->lastRequest = tr_strdup( eventName );
    9781002        evhttp_connection_set_timeout( evcon, REQ_TIMEOUT_INTERVAL_SEC );
    979         httpReq = evhttp_request_new( onTrackerResponse, t );
     1003        httpReq = evhttp_request_new( onTrackerResponse, onTrackerResponseDataNew(t) );
    9801004        addCommonHeaders( t->tracker, httpReq );
    9811005        tr_evhttp_make_request( t->tracker->handle, evcon,
  • trunk/libtransmission/utils.c

    r3164 r3285  
    686686}
    687687
    688 void tr_free( void * p )
     688void
     689tr_free( void * p )
    689690{
    690691    if( p )
Note: See TracChangeset for help on using the changeset viewer.