access FILE pointer after failed fclose() results in undefined behavior
Signed-off-by: Karel Zak <kzak@redhat.com>
int oldumask;
int namelen;
int buflen = 256;
- int contlen;
+ int contlen, rc;
char *linebuf = NULL;
oldumask = umask(0); /* Create with exact permissions */
fputs(linebuf, fp);
}
- if (fclose(fp) < 0)
- goto fail;
+ rc = fclose(fp);
fp = NULL;
+ if (rc < 0)
+ goto fail;
+
close(fd);
fd = -1;
fclose(pwf); /* I don't think I want to know if this failed */