Mercurial > pidgin.yaz
changeset 23595:fe2e20ff3345
fixes a crash and probably more correct and definitely easier to understand
splitting. Fixes #6343. Thanks Dimmuxx for testing since I was too lazy to
do it myself
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Wed, 16 Jul 2008 02:39:15 +0000 |
parents | e216872e6c8a |
children | 73f61c445827 |
files | libpurple/protocols/msn/oim.c |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/oim.c Wed Jul 16 00:59:19 2008 +0000 +++ b/libpurple/protocols/msn/oim.c Wed Jul 16 02:39:15 2008 +0000 @@ -274,22 +274,27 @@ char *oim_base64; char *c; int len; + size_t base64_len; purple_debug_info("msn", "Encoding OIM Message...\n"); len = strlen(body); c = oim_base64 = purple_base64_encode((const guchar *)body, len); + base64_len = strlen(oim_base64); purple_debug_info("msn", "Encoded base64 body:{%s}\n", oim_base64); oim_body = g_string_new(NULL); g_string_printf(oim_body, MSN_OIM_MSG_TEMPLATE, - oim->run_id, oim->send_seq); + oim->run_id, oim->send_seq, ""); - len = ((len / 3) + 1) * 4 - 76; - while ((c - oim_base64) < len) { - g_string_append_len(oim_body, c, 76); +#define OIM_LINE_LEN 76 + while (base64_len > OIM_LINE_LEN) { + g_string_append_len(oim_body, c, OIM_LINE_LEN); g_string_append_c(oim_body, '\n'); - c += 76; + c += OIM_LINE_LEN; + base64_len -= OIM_LINE_LEN; } +#undef OIM_LINE_LEN + g_string_append(oim_body, c); g_free(oim_base64);