changeset 27424:8368e4fb7d3a

Don't double-free the color hash table when deinitializing both prpl-yahoo and prpl-yahoojp. This caused a crash-at-exit when you had signed onto both types of accounts during your session.
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jul 2009 17:20:00 +0000
parents d4cfd179203b
children 4813810ea7d4
files libpurple/protocols/yahoo/util.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/util.c	Wed Jul 08 17:02:07 2009 +0000
+++ b/libpurple/protocols/yahoo/util.c	Wed Jul 08 17:20:00 2009 +0000
@@ -214,8 +214,12 @@
 
 void yahoo_init_colorht()
 {
+	if (ht != NULL)
+		/* Hash table has already been initialized */
+		return;
+
 	ht = g_hash_table_new(g_str_hash, g_str_equal);
-/* the numbers in comments are what gyach uses, but i think they're incorrect */
+	/* the numbers in comments are what gyach uses, but i think they're incorrect */
 	g_hash_table_insert(ht, "30", "<FONT COLOR=\"#000000\">"); /* black */
 	g_hash_table_insert(ht, "31", "<FONT COLOR=\"#0000FF\">"); /* blue */
 	g_hash_table_insert(ht, "32", "<FONT COLOR=\"#008080\">"); /* cyan */      /* 00b2b2 */
@@ -284,7 +288,12 @@
 
 void yahoo_dest_colorht()
 {
+	if (ht == NULL)
+		/* Hash table has already been destroyed */
+		return;
+
 	g_hash_table_destroy(ht);
+	ht = NULL;
 }
 
 static int point_to_html(int x)