changeset 1829:bdfb37ae28b4

[gaim-migrate @ 1839] not that anything uses this committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 09 May 2001 09:56:18 +0000
parents 643872269616
children 086213e7fb73
files src/util.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.c	Wed May 09 05:24:50 2001 +0000
+++ b/src/util.c	Wed May 09 09:56:18 2001 +0000
@@ -591,7 +591,7 @@
 
 	c = text;
 
-	while (c) {
+	while (*c) {
 		tmp = tmp << 8;
 		tmp += *c;
 		n++;
@@ -611,17 +611,19 @@
 	switch (n) {
 
 	case 2:
+		tmp <<= 8;
 		out = g_realloc(out, len + 5);
-		out[len] = alphabet[(tmp >> 12) & 0x3f];
-		out[len + 1] = alphabet[(tmp >> 6) & 0x3f];
-		out[len + 2] = alphabet[tmp & 0x3f];
+		out[len] = alphabet[(tmp >> 18) & 0x3f];
+		out[len + 1] = alphabet[(tmp >> 12) & 0x3f];
+		out[len + 2] = alphabet[(tmp >> 6) & 0x3f];
 		out[len + 3] = '=';
 		out[len + 4] = 0;
 		break;
 	case 1:
+		tmp <<= 16;
 		out = g_realloc(out, len + 4);
-		out[len] = alphabet[(tmp >> 6) & 0x3f];
-		out[len + 1] = alphabet[tmp & 0x3f];
+		out[len] = alphabet[(tmp >> 12) & 0x3f];
+		out[len + 1] = alphabet[(tmp >> 6) & 0x3f];
 		out[len + 2] = '=';
 		out[len + 3] = 0;
 		break;