# HG changeset patch # User Richard Laager # Date 1138905748 0 # Node ID 5a7c4570d768a1e08c34da5303d68d5c42e2bfbc # Parent 8c87818c98a1db6a8dbe7763bc595292d0566ecb [gaim-migrate @ 15457] Add some g_return_val_if_fail() guards to our local implementations of g_str_has_prefix() and g_str_has_suffix(). Glib has these, and it may help prevent crashes. committer: Tailor Script diff -r 8c87818c98a1 -r 5a7c4570d768 src/util.c --- a/src/util.c Thu Feb 02 13:18:18 2006 +0000 +++ b/src/util.c Thu Feb 02 18:42:28 2006 +0000 @@ -2484,10 +2484,10 @@ #if GLIB_CHECK_VERSION(2,2,0) return g_str_has_prefix(s, p); #else - if (!strncmp(s, p, strlen(p))) - return TRUE; - - return FALSE; + g_return_val_if_fail(s != NULL, FALSE); + g_return_val_if_fail(p != NULL, FALSE); + + return (!strncmp(s, p, strlen(p))); #endif } @@ -2497,12 +2497,13 @@ #if GLIB_CHECK_VERSION(2,2,0) return g_str_has_suffix(s, x); #else - int off = strlen(s) - strlen(x); - - if (off >= 0 && !strcmp(s + off, x)) - return TRUE; - - return FALSE; + int off; + + g_return_val_if_fail(s != NULL, FALSE); + g_return_val_if_fail(x != NULL, FALSE); + + off = strlen(s) - strlen(x); + return (off >= 0 && !strcmp(s + off, x)); #endif }