diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 9f53da0c0..d8cad0dac 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -287,11 +287,15 @@ tr_torrentParse( const tr_handle_t * h, if( setme_info == NULL ) setme_info = &tmp; + memset( setme_info, 0, sizeof( tr_info_t ) ); ret = tr_metainfoParseFile( setme_info, h->tag, path, FALSE ); if( ret == TR_OK ) ret = infoCanAdd( h, destination, setme_info ); + if( setme_info == &tmp ) + tr_metainfoFree( &tmp ); + return ret; } @@ -329,11 +333,15 @@ tr_torrentParseHash( const tr_handle_t * h, if( setme_info == NULL ) setme_info = &tmp; + memset( setme_info, 0, sizeof( tr_info_t ) ); ret = tr_metainfoParseHash( setme_info, h->tag, hashStr ); if( ret == TR_OK ) ret = infoCanAdd( h, destination, setme_info ); + if( setme_info == &tmp ) + tr_metainfoFree( &tmp ); + return ret; } @@ -373,11 +381,15 @@ tr_torrentParseData( const tr_handle_t * h, if( setme_info == NULL ) setme_info = &tmp; + memset( setme_info, 0, sizeof( tr_info_t ) ); ret = tr_metainfoParseData( setme_info, h->tag, data, size, FALSE ); if( ret == TR_OK ) ret = infoCanAdd( h, destination, setme_info ); + if( setme_info == &tmp ) + tr_metainfoFree( &tmp ); + return ret; }