]> granicus.if.org Git - mutt/commitdiff
Don't core dump when locking a folder fails.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 23 Feb 2000 08:10:48 +0000 (08:10 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 23 Feb 2000 08:10:48 +0000 (08:10 +0000)
mx.c
mx.h

diff --git a/mx.c b/mx.c
index 1b6e98e5e76e373535ebc12f376876150c40df33..309ea5011d46a5f1616b1bcdd25d98bb3c51ce72 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -274,23 +274,6 @@ int mx_unlock_file (const char *path, int fd, int dot)
   return 0;
 }
 
-/* open a file and lock it */
-FILE *mx_open_file_lock (const char *path, const char *mode)
-{
-  FILE *f;
-
-  if ((f = safe_fopen (path, mode)) != NULL)
-  {
-    if (mx_lock_file (path, fileno (f), *mode != 'r', 1, 1) != 0)
-    {
-      fclose (f);
-      f = NULL;
-    }
-  }
-
-  return (f);
-}
-
 void mx_unlink_empty (const char *path)
 {
   int fd;
@@ -405,7 +388,7 @@ int mx_get_magic (const char *path)
       magic = M_MBOX;
     else if (mutt_strcmp (MMDF_SEP, tmp) == 0)
       magic = M_MMDF;
-    fclose (f);
+    safe_fclose (&f);
 #ifndef BUFFY_SIZE
     /* need to restore the times here, the file was not really accessed,
      * only the type was accessed.  This is important, because detection
@@ -552,7 +535,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx)
        else
        {
          mutt_error (_("Couldn't lock %s\n"), ctx->path);
-         fclose (ctx->fp);
+         safe_fclose (&ctx->fp);
        }
        return (-1);
       }
@@ -715,8 +698,7 @@ void mx_fastclose_mailbox (CONTEXT *ctx)
   safe_free ((void **) &ctx->pattern);
   if (ctx->limit_pattern) 
     mutt_pattern_free (&ctx->limit_pattern);
-  if (ctx->fp)
-    fclose (ctx->fp);
+  safe_fclose (ctx->fp);
   memset (ctx, 0, sizeof (CONTEXT));
 }
 
diff --git a/mx.h b/mx.h
index c8a35ec0783e68c208243cd355daec79702a9ddd..9f85d2a24f2d6bf71323aaf30b6f2b83f1294b7a 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -75,8 +75,6 @@ void mx_alloc_memory (CONTEXT *);
 void mx_update_context (CONTEXT *);
 void mx_update_tables (CONTEXT *, int);
 
-FILE *mx_open_file_lock (const char *, const char *);
-
 
 int mx_lock_file (const char *, int, int, int, int);
 int mx_unlock_file (const char *path, int fd, int dot);