telepathy-gabble: Fix allocation of the string passed to g_base64_encode_step.
Will Thompson
wjt at kemper.freedesktop.org
Wed Nov 14 07:54:00 PST 2012
Module: telepathy-gabble
Branch: master
Commit: eae50abaec48f182b9cbe4cd2d0882f20c04be65
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=eae50abaec48f182b9cbe4cd2d0882f20c04be65
Author: Alban Browaeys <prahal at yahoo.com>
Date: Tue Nov 13 18:49:17 2012 +0100
Fix allocation of the string passed to g_base64_encode_step.
As per g_base64 documentation the minimum size is :
avatar->len / 3 + 1) *4 + 4)
and if line breaks are enabled:
+ ((avatar->len / 3 + 1) * 4 + 4) / 72 + 1
https://bugs.freedesktop.org/show_bug.cgi?id=57080
---
src/conn-avatars.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/conn-avatars.c b/src/conn-avatars.c
index 31d3efc..34ca5f8 100644
--- a/src/conn-avatars.c
+++ b/src/conn-avatars.c
@@ -840,7 +840,7 @@ gabble_connection_set_avatar (TpSvcConnectionInterfaceAvatars *iface,
gint state = 0, save = 0, outlen;
ctx->avatar = g_string_new_len (avatar->data, avatar->len);
- base64 = g_malloc ((avatar->len / 3 + 1) * 4 + 1);
+ base64 = g_malloc (((avatar->len / 3 + 1) *4 + 4) + ((avatar->len / 3 + 1) * 4 + 4) / 72 + 1);
outlen = g_base64_encode_step ((const guchar *) avatar->data,
avatar->len, TRUE, base64, &state, &save);
outlen += g_base64_encode_close (TRUE, base64 + outlen, &state, &save);
More information about the telepathy-commits
mailing list