From 5daca042c642bf123f0b0a39c1ad32ca0afcac70 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Fri, 3 Aug 2012 01:01:21 +0200 Subject: [PATCH] filebuf: Check the return value for `close` --- src/filebuf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/filebuf.c b/src/filebuf.c index 876f8e3e7..8b3ebb3e2 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -319,10 +319,15 @@ int git_filebuf_commit(git_filebuf *file, mode_t mode) if (verify_last_error(file) < 0) goto on_error; - p_close(file->fd); - file->fd = -1; file->fd_is_open = false; + if (p_close(file->fd) < 0) { + giterr_set(GITERR_OS, "Failed to close file at '%s'", file->path_lock); + goto on_error; + } + + file->fd = -1; + if (p_chmod(file->path_lock, mode)) { giterr_set(GITERR_OS, "Failed to set attributes for file at '%s'", file->path_lock); goto on_error; -- 2.39.2