Changeset 13109


Ignore:
Timestamp:
Dec 14, 2011, 5:40:21 AM (10 years ago)
Author:
jordan
Message:

(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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r13080 r13109  
    979979{
    980980    bool valid;
    981     const int len = url ? strlen(url) : 0;
    982 
    983     valid = isValidURLChars( url, len )
    984          && !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
    985          && ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
     981
     982    if( url == NULL )
     983    {
     984        valid = false;
     985    }
     986    else
     987    {
     988        const int len = strlen( url );
     989
     990        valid = isValidURLChars( url, len )
     991            && !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
     992            && ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
     993    }
    986994
    987995    return valid;
     
    9931001{
    9941002    bool valid;
    995     if( ( url_len < 0 ) && ( url != NULL ) )
    996         url_len = strlen( url );
    997 
    998     valid = isValidURLChars( url, url_len )
    999          && !tr_urlParse( url, url_len, NULL, NULL, NULL, NULL )
    1000          && ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"ftp://",6) || !memcmp(url,"sftp://",7) );
     1003
     1004    if( url == NULL )
     1005    {
     1006        valid = false;
     1007    }
     1008    else
     1009    {
     1010        if( url_len < 0 )
     1011            url_len = strlen( url );
     1012
     1013        valid = isValidURLChars( url, url_len )
     1014            && !tr_urlParse( url, url_len, NULL, NULL, NULL, NULL )
     1015            && ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"ftp://",6) || !memcmp(url,"sftp://",7) );
     1016    }
    10011017
    10021018    return valid;
Note: See TracChangeset for help on using the changeset viewer.