Mercurial > pidgin
diff libpurple/protocols/myspace/message.c @ 20658:7efdc052539d
Fix lots of little memory leaks in the MySpace protocol plugin.
GString's need to be free'd, and the string passed to g_string_new()
is duplicated when inserted into the GString, so it still needs
to be free'd.
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Wed, 26 Sep 2007 07:25:22 +0000 |
| parents | 44b4e8bd759b |
| children | b93e7be3847b |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c Tue Sep 25 21:16:55 2007 +0000 +++ b/libpurple/protocols/myspace/message.c Wed Sep 26 07:25:22 2007 +0000 @@ -80,7 +80,7 @@ purple_debug_info("msim", "msim_escape: msg=%s, ret=%s\n", msg, gs->str); #endif - return gs->str; + return g_string_free(gs, FALSE); } /** @@ -120,7 +120,7 @@ purple_debug_info("msim", "msim_unescape: msg=%s, ret=%s\n", msg, gs->str); #endif - return gs->str; + return g_string_free(gs, FALSE); } /** Create a new MsimMessage. @@ -691,7 +691,7 @@ ++i; } - string = gs->str; + string = g_string_free(gs, FALSE); break; default: @@ -798,7 +798,7 @@ g_string_append(gs, "|"); } - return gs->str; + return g_string_free(gs, FALSE); default: purple_debug_info("msim", "field %s, unknown type %d\n", @@ -1337,9 +1337,7 @@ gs = (GString *)elem->data; /* Duplicate data, so caller can g_free() it. */ - *binary_data = g_new0(char, gs->len); - memcpy(*binary_data, gs->str, gs->len); - + *binary_data = g_memdup(gs->str, gs->len); *binary_length = gs->len; return TRUE;
