# HG changeset patch # User Stu Tomlinson # Date 1259167169 0 # Node ID f4a95b3424d11093dca8e5aa079b6117a6683f54 # Parent b5a4df52fb0fc28eeca1207f11e673ef35d6a1ad Make yahoo_codes_to_html not crash when given an empty string, or a string containing just unknown markup, and add a couple of tests to the testsuite for these. Hopefully fixes https://bugzilla.redhat.com/show_bug.cgi?id=541341 diff -r b5a4df52fb0f -r f4a95b3424d1 libpurple/protocols/yahoo/util.c --- a/libpurple/protocols/yahoo/util.c Wed Nov 25 16:10:28 2009 +0000 +++ b/libpurple/protocols/yahoo/util.c Wed Nov 25 16:39:29 2009 +0000 @@ -656,7 +656,10 @@ /* Strip off the outter HTML node */ /* This probably isn't necessary, especially if we made the outter HTML * node an empty span. But the HTML is simpler this way. */ - xmlstr2 = g_strndup(xmlstr1 + 6, strlen(xmlstr1) - 13); + if (!purple_strequal(xmlstr1, "")) + xmlstr2 = g_strndup(xmlstr1 + 6, strlen(xmlstr1) - 13); + else + xmlstr2 = g_strdup(""); g_free(xmlstr1); esc = g_strescape(x, NULL); diff -r b5a4df52fb0f -r f4a95b3424d1 libpurple/tests/test_yahoo_util.c --- a/libpurple/tests/test_yahoo_util.c Wed Nov 25 16:10:28 2009 +0000 +++ b/libpurple/tests/test_yahoo_util.c Wed Nov 25 16:39:29 2009 +0000 @@ -15,6 +15,10 @@ START_TEST(test_codes_to_html) { + assert_string_equal_free("", + yahoo_codes_to_html("")); + assert_string_equal_free("", + yahoo_codes_to_html("\x1B[12345m")); assert_string_equal_free("plain", yahoo_codes_to_html("plain")); assert_string_equal_free("unknown ansi code",