summaryrefslogtreecommitdiff
path: root/src/file.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-02-12 21:05:47 +1100
committerMaxime Coste <mawww@kakoune.org>2019-02-12 21:05:47 +1100
commit89cd68d8aff07792b03a0affc19dbb01f036f554 (patch)
tree067686d8089c2e720b9de45aa6749f24e3414cae /src/file.cc
parent4dae2c875bf70d87ace53d7b03c4a9289b2bb241 (diff)
Check the return value of the rename call
Diffstat (limited to 'src/file.cc')
-rw-r--r--src/file.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/file.cc b/src/file.cc
index eb26ddc4..b8bf2de8 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -335,8 +335,8 @@ void write_buffer_to_file(Buffer& buffer, StringView filename,
::fsync(fd);
}
- if (replace)
- rename(temp_filename, zfilename);
+ if (replace and rename(temp_filename, zfilename) != 0)
+ throw runtime_error("replacing file failed");
if ((buffer.flags() & Buffer::Flags::File) and
real_path(filename) == real_path(buffer.name()))