mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
(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
1 changed files with 25 additions and 9 deletions
|
@ -978,11 +978,19 @@ bool
|
|||
tr_urlIsValidTracker( const char * url )
|
||||
{
|
||||
bool valid;
|
||||
const int len = url ? strlen(url) : 0;
|
||||
|
||||
valid = isValidURLChars( url, len )
|
||||
&& !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
|
||||
&& ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
|
||||
if( url == NULL )
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int len = strlen( url );
|
||||
|
||||
valid = isValidURLChars( url, len )
|
||||
&& !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
|
||||
&& ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
@ -992,12 +1000,20 @@ bool
|
|||
tr_urlIsValid( const char * url, int url_len )
|
||||
{
|
||||
bool valid;
|
||||
if( ( url_len < 0 ) && ( url != NULL ) )
|
||||
url_len = strlen( url );
|
||||
|
||||
valid = isValidURLChars( url, url_len )
|
||||
&& !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) );
|
||||
if( url == NULL )
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( url_len < 0 )
|
||||
url_len = strlen( url );
|
||||
|
||||
valid = isValidURLChars( url, url_len )
|
||||
&& !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) );
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue