]> granicus.if.org Git - mutt/commitdiff
Fix #1417; thanks to Derek D. Martin <ddm@sophic.org> for the
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 11 Dec 2002 22:47:57 +0000 (22:47 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 11 Dec 2002 22:47:57 +0000 (22:47 +0000)
excellent observation.  (In addition to the fix proper, some
tracking of temporary files is added to mutt's debugging output.)

muttlib.c
pgp.c
protos.h
send.c

index 41f1c0e7d79b631a4c4d4131b58f4aef8e46bd3b..ca66fd42ae15ce35bf19db4559d4d7a2e635ffce 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -182,7 +182,13 @@ void mutt_free_body (BODY **p)
     if (b->parameter)
       mutt_free_parameter (&b->parameter);
     if (b->unlink && b->filename)
+    {
+      dprint (1, (debugfile, "mutt_free_body: Unlinking %s.\n", b->filename));
       unlink (b->filename);
+    }
+    else if (b->filename) 
+      dprint (1, (debugfile, "mutt_free_body: Not unlinking %s.\n", b->filename));
+
     FREE (&b->filename);
     FREE (&b->content);
     FREE (&b->xtype);
@@ -672,9 +678,10 @@ void mutt_free_envelope (ENVELOPE **p)
   FREE (p);
 }
 
-void mutt_mktemp (char *s)
+void _mutt_mktemp (char *s, const char *src, int line)
 {
   snprintf (s, _POSIX_PATH_MAX, "%s/mutt-%s-%d-%d", NONULL (Tempdir), NONULL(Hostname), (int) getpid (), Counter++);
+  dprint (1, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
   unlink (s);
 }
 
diff --git a/pgp.c b/pgp.c
index a2540f0074fbfb7c5a78e0707f406edbe383d44d..8aa6a0078ed1fa3235b2cce6d98a3e548c0c0c86 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -1346,7 +1346,7 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
   }
   
   unlink (pgperrfile);
-  
+
   if ((thepid = pgp_invoke_traditional (&pgpin, NULL, NULL, 
                                        -1, fileno (pgpout), fileno (pgperr),
                                        pgpinfile, keylist, flags)) == -1)
index 2aa8032f071e62384fe5755da3f7536ee6fa1142..809a20ba46ba8811f43e3d6de7fd2d7e5412617b 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -193,7 +193,8 @@ void mutt_make_help (char *, size_t, char *, int, int);
 void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, ENVELOPE *curenv);
 void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out);
 void mutt_message_to_7bit (BODY *, FILE *);
-void mutt_mktemp (char *);
+#define mutt_mktemp(a) _mutt_mktemp (a, __FILE__, __LINE__)
+void _mutt_mktemp (char *, const char *, int);
 void mutt_normalize_time (struct tm *);
 void mutt_paddstr (int, const char *);
 void mutt_parse_mime_message (CONTEXT *ctx, HEADER *);
diff --git a/send.c b/send.c
index 6fff3462789a023806a83a52c9e7b7d8c0147915..2f618f34c0cc4742cb9bfe3b4b629fccfe1154ce 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1039,6 +1039,7 @@ ci_send_message (int flags,               /* send mode */
   BODY *pbody;
   int i, killfrom = 0;
   int fcc_error = 0;
+  int free_clear_content = 0;
 
 #if defined(HAVE_PGP) || defined(HAVE_SMIME)
   BODY *save_content = NULL;
@@ -1491,6 +1492,12 @@ main_loop:
    * - something else.  In this case, it's the same as clear_content.
    */
 
+  /* This is ugly -- lack of "reporting back" from mutt_protect(). */
+  
+  if (clear_content && (msg->content != clear_content)
+      && (msg->content->parts != clear_content))
+    free_clear_content = 1;
+  
 #endif /* HAVE_PGP */
 
   if (!option (OPTNOCURSES) && !(flags & SENDMAILX))
@@ -1651,11 +1658,10 @@ full_fcc:
 
 #if defined(HAVE_PGP) || defined(HAVE_SMIME)
   if (msg->security & ENCRYPT)
-  {
-    /* cleanup structures from the first encryption */
-    mutt_free_body (&clear_content);
     FREE (&pgpkeylist);
-  }
+  
+  if (free_clear_content)
+    mutt_free_body (&clear_content);
 #endif
 
   if (flags & SENDREPLY)