Changeset 13559


Ignore:
Timestamp:
Oct 13, 2012, 4:45:20 PM (9 years ago)
Author:
jordan
Message:

(trunk, gtk) #5088 'gtr_is_supported_url(), gtr_is_magnet_link() aren't NULL-safe' -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/util.c

    r13520 r13559  
    1414#include <errno.h>
    1515#include <stdarg.h>
    16 #include <string.h> /* strchr(), strrchr(), strlen(), strncmp(), strstr() */
     16#include <string.h> /* strchr(), strrchr(), strlen(), strstr() */
    1717
    1818#include <gtk/gtk.h>
     
    171171gtr_is_supported_url( const char * str )
    172172{
    173     return !strncmp( str, "ftp://", 6 )
    174         || !strncmp( str, "http://", 7 )
    175         || !strncmp( str, "https://", 8 );
     173    return ( ( str != NULL ) &&
     174             ( g_str_has_prefix( str, "ftp://" ) ||
     175               g_str_has_prefix( str, "http://" ) ||
     176               g_str_has_prefix( str, "https://" ) ) );
    176177}
    177178
     
    179180gtr_is_magnet_link( const char * str )
    180181{
    181     return !strncmp( str, "magnet:?", 8 );
     182    return ( str != NULL ) &&
     183           ( g_str_has_prefix( str, "magnet:?" ) );
    182184}
    183185
Note: See TracChangeset for help on using the changeset viewer.