<<< Date Index >>>     <<< Thread Index >>>

[PATCH 1 of 4] Try to correct usage of tempfile and *tempfile



1 file changed, 5 insertions(+), 5 deletions(-)
sendlib.c |   10 +++++-----


# HG changeset patch
# User Erik Hovland <erik@xxxxxxxxxxx>
# Date 1237316584 25200
# Branch HEAD
# Node ID 022494f73fa54edbf039dc866fa9999069dcef51
# Parent  2285978866e2e9c788f62ddb7d0eee53afd2a36c
Try to correct usage of tempfile and *tempfile

Since tempfile is a double pointer checking for tempfile
and then dereferencing with *tempfile is not correct.

diff --git a/sendlib.c b/sendlib.c
--- a/sendlib.c
+++ b/sendlib.c
@@ -2025,7 +2025,7 @@
       }
       unlink (msg);
 
-      if (SendmailWait >= 0 && tempfile)
+      if (SendmailWait >= 0 && tempfile && *tempfile)
       {
        /* *tempfile will be opened as stdout */
        if (open (*tempfile, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0600) < 0)
@@ -2049,7 +2049,7 @@
     {
       unlink (msg);
       if (tempfile)
-       FREE (tempfile);                /* __FREE_CHECKED__ */
+       FREE (&tempfile);               /* __FREE_CHECKED__ */
       _exit (S_ERR);
     }
 
@@ -2077,7 +2077,7 @@
     if (waitpid (pid, &st, 0) > 0)
     {
       st = WIFEXITED (st) ? WEXITSTATUS (st) : S_ERR;
-      if (SendmailWait && st == (0xff & EX_OK) && tempfile)
+      if (SendmailWait && st == (0xff & EX_OK) && tempfile && *tempfile)
       {
        unlink (*tempfile); /* no longer needed */
        FREE (tempfile);                /* __FREE_CHECKED__ */
@@ -2087,7 +2087,7 @@
     {
       st = (SendmailWait > 0 && errno == EINTR && SigAlrm) ?
              S_BKG : S_ERR;
-      if (SendmailWait > 0 && tempfile)
+      if (SendmailWait > 0 && tempfile && *tempfile)
       {
        unlink (*tempfile);
        FREE (tempfile);                /* __FREE_CHECKED__ */
@@ -2098,7 +2098,7 @@
     alarm (0);
     sigaction (SIGALRM, &oldalrm, NULL);
 
-    if (kill (ppid, 0) == -1 && errno == ESRCH && tempfile)
+    if (kill (ppid, 0) == -1 && errno == ESRCH && tempfile && *tempfile)
     {
       /* the parent is already dead */
       unlink (*tempfile);