From: Thomas Roessler Date: Wed, 23 Feb 2000 08:10:48 +0000 (+0000) Subject: Don't core dump when locking a folder fails. X-Git-Tag: mutt-1-1-5-rel~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=edc1f246e6010b2fc7607de0d58ec61fa97ed1e9;p=mutt Don't core dump when locking a folder fails. --- diff --git a/mx.c b/mx.c index 1b6e98e5..309ea501 100644 --- 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 c8a35ec0..9f85d2a2 100644 --- 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);