From 49db6a02eee902e64b4695a98509c96bd5e5c071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Tue, 29 Apr 2008 06:57:42 +0000 Subject: [PATCH] Do not try to fdopen() if open() failed --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 5e9ec202..769182f1 100644 --- a/main.c +++ b/main.c @@ -387,12 +387,13 @@ FILE * settings_open_for_write(const char *name) { FILE *fp; - int fd; - if((fd = open(name, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0) + if((fd = open(name, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0) { syslog(LOG_ALERT, "Unable to open settings file \"%s\" -- %s", name, strerror(errno)); + return NULL; + } if((fp = fdopen(fd, "w+")) == NULL) syslog(LOG_ALERT, "Unable to open settings file \"%s\" -- %s",