sequencer.c: check return value of close() in rewrite_file()
[gitweb.git] / sequencer.c
index f93b60f615ca390f16f80f42e13f04dd7d3afacc..e0cc2f777e46f70ba1b393cb97c4bf3a90f09ada 100644 (file)
@@ -2673,7 +2673,8 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
                return error_errno(_("could not open '%s' for writing"), path);
        if (write_in_full(fd, buf, len) < 0)
                rc = error_errno(_("could not write to '%s'"), path);
-       close(fd);
+       if (close(fd) && !rc)
+               rc = error_errno(_("could not close '%s'"), path);
        return rc;
 }