Do not try to fdopen() if open() failed
This commit is contained in:
parent
e3cd6c5836
commit
49db6a02ee
1 changed files with 3 additions and 2 deletions
5
main.c
5
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",
|
||||
|
|
Loading…
Add table
Reference in a new issue