Changeset 2872


Ignore:
Timestamp:
Aug 19, 2007, 4:03:06 AM (15 years ago)
Author:
charles
Message:

better fix for the leak in r2870

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r2870 r2872  
    406406                 tr_info_t          * setme_info )
    407407{
    408     int ret;
     408    int ret, doFree;
    409409    tr_info_t tmp;
    410410
     
    414414    memset( setme_info, 0, sizeof( tr_info_t ) );
    415415    ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE );
     416    doFree = !ret && (setme_info == &tmp);
    416417
    417418    if( ret == TR_OK )
    418419        ret = infoCanAdd( h, destination, setme_info );
    419420
    420     if( setme_info == &tmp )
     421    if( doFree )
    421422        tr_metainfoFree( &tmp );
    422423
     
    456457                     tr_info_t          * setme_info )
    457458{
    458     int ret;
     459    int ret, doFree;
    459460    tr_info_t tmp;
    460461
     
    464465    memset( setme_info, 0, sizeof( tr_info_t ) );
    465466    ret = tr_metainfoParseHash( setme_info, h->tag, hashStr );
     467    doFree = !ret && (setme_info == &tmp);
    466468
    467469    if( ret == TR_OK )
    468470        ret = infoCanAdd( h, destination, setme_info );
    469471
    470     if( setme_info == &tmp )
     472    if( doFree )
    471473        tr_metainfoFree( &tmp );
    472474
     
    507509                     tr_info_t          * setme_info )
    508510{
    509     int ret;
     511    int ret, doFree;
    510512    tr_info_t tmp;
    511513
     
    515517    memset( setme_info, 0, sizeof( tr_info_t ) );
    516518    ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE );
     519    doFree = !ret && (setme_info == &tmp);
    517520
    518521    if( ret == TR_OK )
    519522        ret = infoCanAdd( h, destination, setme_info );
    520523
    521     if( setme_info == &tmp )
     524    if( doFree )
    522525        tr_metainfoFree( &tmp );
    523526
Note: See TracChangeset for help on using the changeset viewer.