[gaim-migrate @ 16113]

Mon, 01 May 2006 20:27:49 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Mon, 01 May 2006 20:27:49 +0000
changeset 13711
f4af8af0b643
parent 13710
c8376b63ca31
child 13712
fa55fb41ed0d

[gaim-migrate @ 16113]
CID 154:

File: gaim/src/prefs.c
Function: gaim_prefs_rename_boolean_toggle
Description: Pointer returned from "find_pref" is never used

newpref was only examined in g_return_if_fail() statements, which can be compiled out. It's probably safer to do these sanity checks all the time, given that plugins could call this, etc. etc.

src/prefs.c file | annotate | diff | comparison | revisions
--- a/src/prefs.c	Mon May 01 19:48:57 2006 +0000
+++ b/src/prefs.c	Mon May 01 20:27:49 2006 +0000
@@ -953,23 +953,42 @@
 		struct gaim_pref *oldpref, *newpref;
 
 		oldpref = find_pref(oldname);
-		newpref = find_pref(newname);
 
 		/* it's already been renamed, call off the cats */
 		if(!oldpref)
 			return;
 
-		gaim_debug_info("prefs", "Renaming and toggling %s to %s\n", oldname, newname);
+		if (oldpref->type != GAIM_PREF_BOOLEAN)
+		{
+			gaim_debug_error("prefs", "Unable to rename %s to %s: old pref not a boolean\n", oldname, newname);
+			return;
+		}
+
+		if (oldpref->first_child != NULL) /* can't rename parents */
+		{
+			gaim_debug_error("prefs", "Unable to rename %s to %s: can't rename parents\n", oldname, newname);
+			return;
+		}
+
 
-		g_return_if_fail(newpref != NULL); /* the new one needs to be created */
-		g_return_if_fail(oldpref->type == newpref->type);
-		g_return_if_fail(oldpref->type == GAIM_PREF_BOOLEAN);
-		g_return_if_fail(oldpref->first_child == NULL); /* can't rename parents */
+		newpref = find_pref(newname);
+
+		if (newpref == NULL)
+		{
+			gaim_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname);
+			return;
+		}
 
+		if (oldpref->type != newpref->type)
+		{
+			gaim_debug_error("prefs", "Unable to rename %s to %s: differing types\n", oldname, newname);
+			return;
+		}
+
+		gaim_debug_info("prefs", "Renaming and toggling %s to %s\n", oldname, newname);
 		gaim_prefs_set_bool(newname, !(oldpref->value.boolean));
 
 		remove_pref(oldpref);
-
 }
 
 guint

mercurial