vfs: don't crash if copy_file can't open output file (LP 1687283)

This commit is contained in:
rdb 2017-07-10 21:10:47 +02:00
parent 8b3ad7348e
commit 1b690e528f
1 changed files with 9 additions and 0 deletions

View File

@ -150,7 +150,16 @@ copy_file(VirtualFile *new_file) {
// Different mount point, or the mount doesn't support copying. Do it by
// hand.
ostream *out = new_file->open_write_file(false, true);
if (out == nullptr) {
return false;
}
istream *in = open_read_file(false);
if (in == nullptr) {
new_file->close_write_file(out);
new_file->delete_file();
return false;
}
static const size_t buffer_size = 4096;
char buffer[buffer_size];