pidgin: 76356e29: Fix a leak "KuSh" discovered using "cppc...
datallah at pidgin.im
datallah at pidgin.im
Mon Dec 22 12:05:56 EST 2008
-----------------------------------------------------------------
Revision: 76356e2951dc266397980d06c3480b550cd174d9
Ancestor: 724fba520cfff8d0db07424c911a91b93d0cf0ad
Author: datallah at pidgin.im
Date: 2008-12-22T16:41:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/76356e2951dc266397980d06c3480b550cd174d9
Modified files:
libpurple/protocols/gg/buddylist.c
ChangeLog:
Fix a leak "KuSh" discovered using "cppcheck". Fixes #7858. Also, make the relevant code less of a horrible abomination.
-------------- next part --------------
============================================================
--- libpurple/protocols/gg/buddylist.c bb4df146e151d8cb4b852cd2346cb51306106958
+++ libpurple/protocols/gg/buddylist.c 6419e006f2a2e95d31e135aeeb194f1948dde634
@@ -216,13 +216,14 @@ char *ggp_buddylist_dump(PurpleAccount *
PurpleBlistNode *gnode, *cnode, *bnode;
PurpleGroup *group;
PurpleBuddy *buddy;
-
- char *buddylist = g_strdup("");
+ GString *buddylist;
char *ptr;
if ((blist = purple_get_blist()) == NULL)
return NULL;
+ buddylist = g_string_sized_new(1024);
+
for (gnode = blist->root; gnode != NULL; gnode = gnode->next) {
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
continue;
@@ -247,19 +248,16 @@ char *ggp_buddylist_dump(PurpleAccount *
alias = buddy->alias ? buddy->alias : buddy->name;
gname = group->name;
- ptr = buddylist;
- buddylist = g_strdup_printf(
- "%s%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
- ptr, alias, alias, alias, alias,
+ g_string_append_printf(buddylist,
+ "%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
+ alias, alias, alias, alias,
"", gname, name, "", "");
-
- g_free(ptr);
}
}
}
- ptr = charset_convert(buddylist, "UTF-8", "CP1250");
- g_free(buddylist);
+ ptr = charset_convert(buddylist->str, "UTF-8", "CP1250");
+ g_string_free(buddylist, TRUE);
return ptr;
}
/* }}} */
More information about the Commits
mailing list