1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

* fix memory leak when adding torrents.

* zero out tr_torrentParse()'s tr_info_t before filling it
This commit is contained in:
Charles Kerr 2007-06-28 01:12:16 +00:00
parent ae40410b4e
commit 8aa002b25e

View file

@ -287,11 +287,15 @@ tr_torrentParse( const tr_handle_t * h,
if( setme_info == NULL ) if( setme_info == NULL )
setme_info = &tmp; setme_info = &tmp;
memset( setme_info, 0, sizeof( tr_info_t ) );
ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE ); ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE );
if( ret == TR_OK ) if( ret == TR_OK )
ret = infoCanAdd( h, destination, setme_info ); ret = infoCanAdd( h, destination, setme_info );
if( setme_info == &tmp )
tr_metainfoFree( &tmp );
return ret; return ret;
} }
@ -329,11 +333,15 @@ tr_torrentParseHash( const tr_handle_t * h,
if( setme_info == NULL ) if( setme_info == NULL )
setme_info = &tmp; setme_info = &tmp;
memset( setme_info, 0, sizeof( tr_info_t ) );
ret = tr_metainfoParseHash( setme_info, h->tag, hashStr ); ret = tr_metainfoParseHash( setme_info, h->tag, hashStr );
if( ret == TR_OK ) if( ret == TR_OK )
ret = infoCanAdd( h, destination, setme_info ); ret = infoCanAdd( h, destination, setme_info );
if( setme_info == &tmp )
tr_metainfoFree( &tmp );
return ret; return ret;
} }
@ -373,11 +381,15 @@ tr_torrentParseData( const tr_handle_t * h,
if( setme_info == NULL ) if( setme_info == NULL )
setme_info = &tmp; setme_info = &tmp;
memset( setme_info, 0, sizeof( tr_info_t ) );
ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE ); ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE );
if( ret == TR_OK ) if( ret == TR_OK )
ret = infoCanAdd( h, destination, setme_info ); ret = infoCanAdd( h, destination, setme_info );
if( setme_info == &tmp )
tr_metainfoFree( &tmp );
return ret; return ret;
} }