瀏覽代碼

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

rdb 8 年之前
父節點
當前提交
1b690e528f
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      panda/src/express/virtualFileSimple.cxx

+ 9 - 0
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];