Fix compilation error
[apps/madmutt.git] / mutt_libesmtp.c
index 9df7ffb..7142fbd 100644 (file)
@@ -144,7 +144,7 @@ static const char *_mutt_libesmtp_messagefp_cb (void **buf, int *len,
   int octets;
 
   if (*buf == NULL)
-    *buf = malloc (BUFLEN);
+    *buf = xmalloc(BUFLEN);
 
   if (len == NULL) {
     rewind ((FILE *) arg);
@@ -158,7 +158,7 @@ static const char *_mutt_libesmtp_messagefp_cb (void **buf, int *len,
     char *p = strchr (*buf, '\0');
 
     if (p[-1] == '\n' && p[-2] != '\r') {
-      m_strcpy(p - 1, "\r\n");
+      m_strcpy(p - 1, (char *) *buf + BUFLEN - p + 1, "\r\n");
       p++;
     }
     octets = p - (char *) *buf;