summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tempfile.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tempfile.c b/tempfile.c
index ffcc272375..6843710670 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -247,8 +247,13 @@ int close_tempfile(struct tempfile *tempfile)
tempfile->fd = -1;
if (fp) {
tempfile->fp = NULL;
- err = ferror(fp);
- err |= fclose(fp);
+ if (ferror(fp)) {
+ err = -1;
+ if (!fclose(fp))
+ errno = EIO;
+ } else {
+ err = fclose(fp);
+ }
} else {
err = close(fd);
}