Mercurial > pidgin
comparison src/util.c @ 7265:d565594c1bae
[gaim-migrate @ 7842]
fix the base64 encode function to allocate the right amount of memory.
this fixes an issue logging into jabberd 2.0 servers, and probably a few other things
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 14 Oct 2003 21:17:20 +0000 |
parents | 85fcaff1505d |
children | 3a41c3f80228 |
comparison
equal
deleted
inserted
replaced
7264:deab8d8bbb4e | 7265:d565594c1bae |
---|---|
140 char *out, *rv; | 140 char *out, *rv; |
141 | 141 |
142 g_return_val_if_fail(in != NULL, NULL); | 142 g_return_val_if_fail(in != NULL, NULL); |
143 g_return_val_if_fail(inlen > 0, NULL); | 143 g_return_val_if_fail(inlen > 0, NULL); |
144 | 144 |
145 rv = out = g_malloc((4 * (inlen + 1)) / 3 + 1); | 145 rv = out = g_malloc(((inlen/3)+1)*4 + 1); |
146 | 146 |
147 for (; inlen >= 3; inlen -= 3) | 147 for (; inlen >= 3; inlen -= 3) |
148 { | 148 { |
149 *out++ = alphabet[in[0] >> 2]; | 149 *out++ = alphabet[in[0] >> 2]; |
150 *out++ = alphabet[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | 150 *out++ = alphabet[((in[0] << 4) & 0x30) | (in[1] >> 4)]; |