diff src/util.c @ 13095:5a7c4570d768

[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 <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 02 Feb 2006 18:42:28 +0000
parents b553326bc468
children f1bf8989bbf2
line wrap: on
line diff
--- 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
 }