From 031e313aa27f4db8daaf981eb48060670e6cb6bd Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 14 Oct 2012 18:10:17 +0000 Subject: [PATCH] (trunk, libT) #5081 'Transmission discards webseed URLs that have trailing whitespace' -- fixed. Unit test passes and valgrind says 'All heap blocks were freed -- no leaks are possible' --- libtransmission/metainfo-test.c | 2 +- libtransmission/metainfo.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libtransmission/metainfo-test.c b/libtransmission/metainfo-test.c index 71fca392e..51da5b179 100644 --- a/libtransmission/metainfo-test.c +++ b/libtransmission/metainfo-test.c @@ -1,7 +1,7 @@ #include "transmission.h" #include "utils.h" /* tr_strcmp0 */ -#define VERBOSE +#undef VERBOSE #include "libtransmission-test.h" static int diff --git a/libtransmission/metainfo.c b/libtransmission/metainfo.c index aab3aa2e6..64961dc40 100644 --- a/libtransmission/metainfo.c +++ b/libtransmission/metainfo.c @@ -371,10 +371,15 @@ getannounce( tr_info * inf, tr_benc * meta ) * trailing slash for multifile torrents if omitted by the end user. */ static char* -fix_webseed_url( const tr_info * inf, const char * url ) +fix_webseed_url( const tr_info * inf, const char * url_in ) { + size_t len; + char * url; char * ret = NULL; - const size_t len = strlen( url ); + + url = tr_strdup( url_in ); + tr_strstrip( url ); + len = strlen( url ); if( tr_urlIsValid( url, len ) ) { @@ -384,6 +389,7 @@ fix_webseed_url( const tr_info * inf, const char * url ) ret = tr_strndup( url, len ); } + tr_free( url ); return ret; } -- 2.40.0