am: fix signoff when other trailers are present
[gitweb.git] / tempfile.c
index ffcc2723755f1b97dd6626ed7c13801f905fdf18..68437106703470f39a6079aaad7d3bb407ac3389 100644 (file)
@@ -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);
        }