# HG changeset patch # User Mark Doliner # Date 1088305984 0 # Node ID 379f59c5b1ff6779162cbe9d8ab7bfa9b328c0c9 # Parent 0df0a192f382541365459e9f86351e10cec259ac [gaim-migrate @ 10222] Andrew Wellington says, "Returning a local buffer is not a good idea, it'll work sometimes for some platforms, but the rest of the time it'll give garbage This patch changes oscar_caps_to_string to return a g_malloc()'d block, that is then g_free()'d by the caller." I mostly disagreed with him, but this change doesn't seem like such a bad idea regardless. See http://sourceforge.net/tracker/index.php?func=detail&aid=976213&group_id=235&atid=300235 committer: Tailor Script diff -r 0df0a192f382 -r 379f59c5b1ff src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Sat Jun 26 20:33:01 2004 +0000 +++ b/src/protocols/oscar/oscar.c Sun Jun 27 03:13:04 2004 +0000 @@ -418,12 +418,14 @@ return utf8; } -static char *oscar_caps_to_string(guint caps) +gchar *oscar_caps_to_string(guint caps) { - static char buf[512], *tmp; - int count = 0, i = 0; + GString *str; + gchar *tmp; guint bit = 1; + str = g_string_new(""); + if (!caps) { return NULL; } else while (bit <= AIM_CAPS_LAST) { @@ -505,13 +507,12 @@ break; } if (tmp) - i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), - tmp); - count++; + g_string_append_printf(str, "%s%s", (bit == 1 ? "" : ", "), tmp); } bit <<= 1; } - return buf; + + return g_string_free(str, FALSE); } static char *oscar_icqstatus(int state) { @@ -596,6 +597,7 @@ if ((userinfo != NULL) && (userinfo->capabilities != 0)) { tmp = oscar_caps_to_string(userinfo->capabilities); oscar_string_append(str, newline, _("Capabilities"), tmp); + g_free(tmp); } if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) {