]> git.eshelyaron.com Git - emacs.git/commitdiff
(Fbase64_encode_string): Allocate sufficient memory for
authorKenichi Handa <handa@m17n.org>
Thu, 4 Mar 1999 11:35:42 +0000 (11:35 +0000)
committerKenichi Handa <handa@m17n.org>
Thu, 4 Mar 1999 11:35:42 +0000 (11:35 +0000)
newlines added when the arg NO-LINE-BREAK is nil.

src/fns.c

index c1e8867e80d4b7982bc60d42603e2c77e5c87878..401789e2bab3583e5436c96d0a6e07237940e5cb 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -2910,8 +2910,12 @@ into shorter lines.")
 
   CHECK_STRING (string, 1);
 
+  /* We need to allocate enough room for encoding the text.
+     We need 33 1/3% more space, plus a newline every 76
+     characters, and then we round up. */
   length = STRING_BYTES (XSTRING (string));
-  allength = length + length/3 + 1 + 6;
+  allength = length + length/3 + 1;
+  allength += allength / MIME_LINE_LENGTH + 1 + 6;
 
   /* We need to allocate enough room for decoding the text. */
   if (allength <= MAX_ALLOCA)