]> granicus.if.org Git - mutt/commitdiff
Fixing a memory hog which was introduced by the edit-message patch.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 15 Oct 1998 01:17:41 +0000 (01:17 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 15 Oct 1998 01:17:41 +0000 (01:17 +0000)
12 files changed:
buffy.c
headers.c
imap.c
main.c
mbox.c
mh.c
parse.c
parse.h
po/mutt.pot
postpone.c
protos.h
sendlib.c

diff --git a/buffy.c b/buffy.c
index a90730a71c6d816795391f1d2855b7e2dc369fdd..512d70b0283ba7463194c622fe73bb270ca3201d 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -97,7 +97,7 @@ int test_last_status_new (FILE * f)
     return (0);
 
   hdr = mutt_new_header ();
-  mutt_read_rfc822_header (f, hdr);
+  mutt_read_rfc822_header (f, hdr, 0);
   if (!(hdr->read || hdr->old))
     result = 1;
   mutt_free_header (&hdr);
index e4ea13da0318bf3e3000468b1a231cae8af20fd3..e92ba3402fa272d62af877ef3aeda7b931a641a7 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -129,7 +129,7 @@ void mutt_edit_headers (const char *editor,
   /* Read the temp file back in */
   ifp = fopen (path, "r");
   ofp = safe_fopen (body, "w");
-  n = mutt_read_rfc822_header (ifp, NULL);
+  n = mutt_read_rfc822_header (ifp, NULL, 1);
   while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0)
     fwrite (buffer, 1, i, ofp);
   fclose (ofp);
diff --git a/imap.c b/imap.c
index 34e5906109079af9ec8b6a07ceb81e7cf06e6264..5e4514bb56c7efe516a661257e1732f366403b60 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -531,7 +531,7 @@ static int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend)
     ctx->hdrs[ctx->msgcount] = mutt_new_header ();
     ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
 
-    ctx->hdrs[msgno]->env = mutt_read_rfc822_header (fp, ctx->hdrs[msgno]);
+    ctx->hdrs[msgno]->env = mutt_read_rfc822_header (fp, ctx->hdrs[msgno], 0);
     ploc=ftell(fp);
     ctx->hdrs[msgno]->read = h->read;
     ctx->hdrs[msgno]->old = h->old;
diff --git a/main.c b/main.c
index 249dbc6d85ad26bbdc16fa628fc4b6de138256bb..a004179062642603cdf9e841c5c4cf9b4ac919bf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -568,7 +568,7 @@ int main (int argc, char **argv)
       tempfile = safe_strdup (buf);
 
       if (draftFile)
-       msg->env = mutt_read_rfc822_header (fin, NULL);
+       msg->env = mutt_read_rfc822_header (fin, NULL, 1);
 
       if (tempfile)
       {
diff --git a/mbox.c b/mbox.c
index 54153eab3faf4b4dc59df0d93deaf7c42e6b2965..f644e7aab7ee86d490599b8a71a2a9b27810c26d 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -135,7 +135,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
       else
        hdr->received = t + tz;
 
-      hdr->env = mutt_read_rfc822_header (ctx->fp, hdr);
+      hdr->env = mutt_read_rfc822_header (ctx->fp, hdr, 0);
 
       loc = ftell (ctx->fp);
 
@@ -270,7 +270,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
       curhdr->offset = loc;
       curhdr->index = ctx->msgcount;
        
-      curhdr->env = mutt_read_rfc822_header (ctx->fp, curhdr);
+      curhdr->env = mutt_read_rfc822_header (ctx->fp, curhdr, 0);
 
       /* if we know how long this message is, either just skip over the body,
        * or if we don't know how many lines there are, count them now (this will
diff --git a/mh.c b/mh.c
index 99f55ec38df0f7f620351fa2d75ab145a602b5b1..c8b7843531d1098c476b6410d78a7c1b5bd617e8 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -132,7 +132,7 @@ static HEADER *maildir_parse_message(int magic, const char *fname, int is_old)
   if ((f = fopen (fname, "r")) != NULL)
   {
     h = mutt_new_header();
-    h->env = mutt_read_rfc822_header (f, h);
+    h->env = mutt_read_rfc822_header (f, h, 0);
 
     fstat (fileno (f), &st);
     fclose (f);
diff --git a/parse.c b/parse.c
index b3558e93a4664c738f3b2a1fc29d35baf8cc1838..64ed48ed89e86b0e47f54ef16e041eff61ad7b0a 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -423,7 +423,7 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent)
 
   parent->hdr = mutt_new_header ();
   parent->hdr->offset = ftell (fp);
-  parent->hdr->env = mutt_read_rfc822_header (fp, parent->hdr);
+  parent->hdr->env = mutt_read_rfc822_header (fp, parent->hdr, 0);
   msg = parent->hdr->content;
 
   /* ignore the length given in the content-length since it could be wrong
@@ -835,12 +835,13 @@ void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur)
  *
  * f           stream to read from
  *
- * hdr         header structure of current message (optional).  If hdr is
- *             NULL, then we are reading a postponed message, or called
- *             from mutt_edit_headers() so we should keep a list of the
- *             user-defined headers.
+ * hdr         header structure of current message (optional).
+ * 
+ * user_hdrs   If set, store user headers.  Used for edit-message and 
+ *             postpone modes.
+ * 
  */
-ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr)
+ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs)
 {
   ENVELOPE *e = mutt_new_envelope();
   LIST *last = NULL;
@@ -1156,7 +1157,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr)
     }
 
      /* Keep track of the user-defined headers */
-    if (!matched)
+    if (!matched && user_hdrs)
     {
       if (last)
       {
diff --git a/parse.h b/parse.h
index 78cfaeb949b52d761e31dd5284b776e03e0961d6..7de662700dae3f939edcb181a67c61c0f446c27a 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -1,8 +1,11 @@
 /* $Id$ */
+
+/* XXX this file duplicates content from protos.h */
+
 BODY *mutt_parse_multipart (FILE *, const char *, long, int);
 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 
-ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *);
+ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short);
 
 time_t is_from (const char *, char *, size_t);
index 9d66e36949bdfd12d68abab4677447edad40976c..05042268f87667bcdf3ae9ec9ffcc6b048d06c86 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1998-10-15 00:54+0200\n"
+"POT-Creation-Date: 1998-10-15 03:08+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2760,17 +2760,17 @@ msgstr ""
 msgid "Could not open %s"
 msgstr ""
 
-#: sendlib.c:1694
+#: sendlib.c:1695
 #, c-format
 msgid "Error sending message, child exited %d (%s).\n"
 msgstr ""
 
-#: sendlib.c:1696
+#: sendlib.c:1697
 #, c-format
 msgid "Saved output of child process to %s.\n"
 msgstr ""
 
-#: sendlib.c:1700
+#: sendlib.c:1701
 msgid "Error sending message."
 msgstr ""
 
index 23711555d96dcc2276c9fa30f91e96435856cd5b..02e18efde6f5913a2024d657ce9818c7366e5503 100644 (file)
@@ -380,7 +380,7 @@ int mutt_edit_message (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr)
     return (-1);
 
   fseek (msg->fp, hdr->offset, 0);
-  newhdr->env = mutt_read_rfc822_header (msg->fp, newhdr);
+  newhdr->env = mutt_read_rfc822_header (msg->fp, newhdr, 1);
 
   if (hdr->content->type == TYPEMESSAGE || hdr->content->type == TYPEMULTIPART)
   {
index db16561270727ab18b795ed68f85c7df2a00245d..e795b10a0f91c1ec32afdcd7617431eba926e150 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -87,7 +87,7 @@ BODY *mutt_parse_multipart (FILE *, const char *, long, int);
 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 
-ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *);
+ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short);
 HEADER *mutt_dup_header (HEADER *);
 
 ATTACHPTR **mutt_gen_attach_list (BODY *, ATTACHPTR **, short *, short *, int, int);
index 8bf1917fe892d487a9028a56290981227b0f6ef5..ccd3444a6903c94e53d8390e359c688eaa2cdf6f 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1024,7 +1024,8 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
 
   body->hdr = mutt_new_header();
   body->hdr->offset = 0;
-  body->hdr->env = mutt_read_rfc822_header(fp, body->hdr);
+  /* we don't need the user headers here */
+  body->hdr->env = mutt_read_rfc822_header(fp, body->hdr, 0);
 #ifdef _PGPPATH
   body->hdr->pgp = pgp;
 #endif /* _PGPPATH */