# HG changeset patch # User Ka-Hing Cheung # Date 1216175955 0 # Node ID fe2e20ff3345a380b0a6e3a72b189dfdec2222ff # Parent e216872e6c8ade783f33191aee4cedd1f06ea062 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 diff -r e216872e6c8a -r fe2e20ff3345 libpurple/protocols/msn/oim.c --- 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);