summaryrefslogtreecommitdiff
path: root/src/filebuf.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2012-08-03 01:01:21 +0200
committerVicent Marti <tanoku@gmail.com>2012-08-03 01:01:21 +0200
commit5daca042c642bf123f0b0a39c1ad32ca0afcac70 (patch)
tree502f489bcbf57b236a2bc6b1110aeb96009a9e30 /src/filebuf.c
parentd96c3863a50f2a9b0f33735911e5472fec3ad288 (diff)
downloadlibgit2-5daca042c642bf123f0b0a39c1ad32ca0afcac70.tar.gz
filebuf: Check the return value for `close`
Diffstat (limited to 'src/filebuf.c')
-rw-r--r--src/filebuf.c9
1 files 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;