From 1b690e528fdea15c7290e015f3ec14fa03e69c6c Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 10 Jul 2017 21:10:47 +0200 Subject: [PATCH] vfs: don't crash if copy_file can't open output file (LP 1687283) --- panda/src/express/virtualFileSimple.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/panda/src/express/virtualFileSimple.cxx b/panda/src/express/virtualFileSimple.cxx index a036c0df4b..1c521b6459 100644 --- a/panda/src/express/virtualFileSimple.cxx +++ b/panda/src/express/virtualFileSimple.cxx @@ -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];