better fix for the leak in r2870

This commit is contained in:
Charles Kerr 2007-08-19 04:03:06 +00:00
parent e19ecccae8
commit 4e82903313
1 changed files with 9 additions and 6 deletions

View File

@ -405,7 +405,7 @@ tr_torrentParse( const tr_handle_t * h,
const char * destination,
tr_info_t * setme_info )
{
int ret;
int ret, doFree;
tr_info_t tmp;
if( setme_info == NULL )
@ -413,11 +413,12 @@ tr_torrentParse( const tr_handle_t * h,
memset( setme_info, 0, sizeof( tr_info_t ) );
ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE );
doFree = !ret && (setme_info == &tmp);
if( ret == TR_OK )
ret = infoCanAdd( h, destination, setme_info );
if( setme_info == &tmp )
if( doFree )
tr_metainfoFree( &tmp );
return ret;
@ -455,7 +456,7 @@ tr_torrentParseHash( const tr_handle_t * h,
const char * destination,
tr_info_t * setme_info )
{
int ret;
int ret, doFree;
tr_info_t tmp;
if( setme_info == NULL )
@ -463,11 +464,12 @@ tr_torrentParseHash( const tr_handle_t * h,
memset( setme_info, 0, sizeof( tr_info_t ) );
ret = tr_metainfoParseHash( setme_info, h->tag, hashStr );
doFree = !ret && (setme_info == &tmp);
if( ret == TR_OK )
ret = infoCanAdd( h, destination, setme_info );
if( setme_info == &tmp )
if( doFree )
tr_metainfoFree( &tmp );
return ret;
@ -506,7 +508,7 @@ tr_torrentParseData( const tr_handle_t * h,
const char * destination,
tr_info_t * setme_info )
{
int ret;
int ret, doFree;
tr_info_t tmp;
if( setme_info == NULL )
@ -514,11 +516,12 @@ tr_torrentParseData( const tr_handle_t * h,
memset( setme_info, 0, sizeof( tr_info_t ) );
ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE );
doFree = !ret && (setme_info == &tmp);
if( ret == TR_OK )
ret = infoCanAdd( h, destination, setme_info );
if( setme_info == &tmp )
if( doFree )
tr_metainfoFree( &tmp );
return ret;