pidgin: dd712fa8: Fix a possible crash when receiving URLs...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue Aug 18 19:55:49 EDT 2009


-----------------------------------------------------------------
Revision: dd712fa84e46b2d78adf28e914d3e1a5c18a5154
Ancestor: 1b3177afd1f9ac62f43488e54b8dd7055cfb1206
Author: markdoliner at pidgin.im
Date: 2009-08-18T23:52:14
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/dd712fa84e46b2d78adf28e914d3e1a5c18a5154

Modified files:
        libpurple/protocols/yahoo/util.c
        libpurple/tests/test_yahoo_util.c

ChangeLog: 

Fix a possible crash when receiving URLs in yahoo.  It doesn't crash for me
but it did for the guy reporting the bug.  Might be architecture
dependent or compile option dependent.  In any case this is bad and we
should release 2.6.1 tonight or tomorrow

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/util.c	3b5fb040d83b95ad19527ffcb954ede41cbbe7ee
+++ libpurple/protocols/yahoo/util.c	31666b2add695540ed3a138e979cdb9a4e0089bf
@@ -553,13 +553,16 @@ char *yahoo_codes_to_html(const char *x)
 #endif /* !USE_CSS_FORMATTING */
 
 				} else if ((match = g_hash_table_lookup(esc_codes_ht, code))) {
-					gboolean is_closing_tag;
-					gchar *tag_name;
+					/* Some tags are in the hash table only because we
+					 * want to ignore them */
+					if (match[0] != '\0') {
+						gboolean is_closing_tag;
+						gchar *tag_name;
+						tag_name = yahoo_markup_get_tag_name(match, &is_closing_tag);
+						yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE);
+						g_free(tag_name);
+					}
 
-					tag_name = yahoo_markup_get_tag_name(match, &is_closing_tag);
-					yahoo_codes_to_html_add_tag(&cur, match, is_closing_tag, tag_name, FALSE);
-					g_free(tag_name);
-
 				} else {
 					purple_debug_error("yahoo",
 						"Ignoring unknown ansi code 'ESC[%sm'.\n", code);
============================================================
--- libpurple/tests/test_yahoo_util.c	19888ffb748a9b4eb657eb6077c675d4efee4928
+++ libpurple/tests/test_yahoo_util.c	948b653aa8f524b8e4570e6e7dae24f843183ed5
@@ -50,6 +50,10 @@ START_TEST(test_codes_to_html)
 	assert_string_equal_free("<b>bold <i>bolditalic <u>bolditalicunderline</u></i></b><i><u> italicunderline</u></i>",
 			yahoo_codes_to_html("\x1B[1mbold \x1B[2mbolditalic \x1B[4mbolditalicunderline\x1B[x1m italicunderline"));
 
+	/* link */
+	assert_string_equal_free("http://pidgin.im/",
+			yahoo_codes_to_html("\x1B[lmhttp://pidgin.im/\x1B[xlm"));
+
 #ifdef USE_CSS_FORMATTING
 	/* font color */
 	assert_string_equal_free("<span style='color: #0000FF'>blue</span>",


More information about the Commits mailing list