Changeset 2216


Ignore:
Timestamp:
Jun 28, 2007, 1:12:16 AM (15 years ago)
Author:
charles
Message:
  • fix memory leak when adding torrents.
  • zero out tr_torrentParse()'s tr_info_t before filling it
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r2215 r2216  
    288288        setme_info = &tmp;
    289289
     290    memset( setme_info, 0, sizeof( tr_info_t ) );
    290291    ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE );
    291292
    292293    if( ret == TR_OK )
    293294        ret = infoCanAdd( h, destination, setme_info );
     295
     296    if( setme_info == &tmp )
     297        tr_metainfoFree( &tmp );
    294298
    295299    return ret;
     
    330334        setme_info = &tmp;
    331335
     336    memset( setme_info, 0, sizeof( tr_info_t ) );
    332337    ret = tr_metainfoParseHash( setme_info, h->tag, hashStr );
    333338
    334339    if( ret == TR_OK )
    335340        ret = infoCanAdd( h, destination, setme_info );
     341
     342    if( setme_info == &tmp )
     343        tr_metainfoFree( &tmp );
    336344
    337345    return ret;
     
    374382        setme_info = &tmp;
    375383
     384    memset( setme_info, 0, sizeof( tr_info_t ) );
    376385    ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE );
    377386
    378387    if( ret == TR_OK )
    379388        ret = infoCanAdd( h, destination, setme_info );
     389
     390    if( setme_info == &tmp )
     391        tr_metainfoFree( &tmp );
    380392
    381393    return ret;
Note: See TracChangeset for help on using the changeset viewer.