(trunk web) fix warnings in tr_urlIsValidTracker() and tr_urlIsValid() found by llvm's scan-build.
scan-build found similar warnings in these two functions relating to allowing NULL pointers to be passed as arguments to functions that don't allow NULL. So now those NULL checks are made explicit before the function calls.
This commit is contained in:
parent
30f7fae5a5
commit
206b1a9a5f
|
@ -978,11 +978,19 @@ bool
|
||||||
tr_urlIsValidTracker( const char * url )
|
tr_urlIsValidTracker( const char * url )
|
||||||
{
|
{
|
||||||
bool valid;
|
bool valid;
|
||||||
const int len = url ? strlen(url) : 0;
|
|
||||||
|
if( url == NULL )
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int len = strlen( url );
|
||||||
|
|
||||||
valid = isValidURLChars( url, len )
|
valid = isValidURLChars( url, len )
|
||||||
&& !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
|
&& !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
|
||||||
&& ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
|
&& ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
|
||||||
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
@ -992,12 +1000,20 @@ bool
|
||||||
tr_urlIsValid( const char * url, int url_len )
|
tr_urlIsValid( const char * url, int url_len )
|
||||||
{
|
{
|
||||||
bool valid;
|
bool valid;
|
||||||
if( ( url_len < 0 ) && ( url != NULL ) )
|
|
||||||
|
if( url == NULL )
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( url_len < 0 )
|
||||||
url_len = strlen( url );
|
url_len = strlen( url );
|
||||||
|
|
||||||
valid = isValidURLChars( url, url_len )
|
valid = isValidURLChars( url, url_len )
|
||||||
&& !tr_urlParse( url, url_len, NULL, NULL, NULL, NULL )
|
&& !tr_urlParse( url, url_len, NULL, NULL, NULL, NULL )
|
||||||
&& ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"ftp://",6) || !memcmp(url,"sftp://",7) );
|
&& ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"ftp://",6) || !memcmp(url,"sftp://",7) );
|
||||||
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue